[Mono-list] Init script with mono-service

Stefano Facchetti - Arcoba Srl s.facchetti at arcoba.it
Wed Nov 19 07:37:27 UTC 2014


Hi,
I'm using:

Mono JIT compiler version 3.8.0 (tarball Thu Sep  4 12:22:04 UTC 2014)
Copyright (C) 2002-2014 Novell, Inc, Xamarin Inc and Contributors. 
www.mono-project.com
         TLS:           __thread
         SIGSEGV:       altstack
         Notifications: epoll
         Architecture:  amd64
         Disabled:      none
         Misc:          softdebug
         LLVM:          supported, not enabled.
         GC:            sgen

on Linux TurnKey core (http://www.turnkeylinux.org/core) based on Debian 
7.2 (Wheezy).


I developed a windows service and I'm trying to use it with mono-service 
command.
Using command mono-service manually from the shell work well.

I've created an init script (in attach) for automatically startup my 
service at machine startup and I've registred it with following command:
update-rc.d myservice defaults

If I run a command like "/etc/init.d/myservice start", all work fine 
while if I run a command like "service myservice start" I have a strange 
behavior:
- cpu load go to 100%
- myservice logic not work
I not understand the difference of the commands above.

When machine starts, I have the same behavior like when I run the 
command "service myservice start".

Can somebody help me?

Best regards,
Stefano.
-------------- next part --------------
#!/bin/bash
#
# Get function from functions library
. /lib/lsb/init-functions

ARCLAUNCHER_HOME="/home/mono"

arclauncher_pid() {
	echo `ps aux | grep ArcLauncher.exe | grep -v grep | awk '{ print $2 }'`
}

# Funzione di avvio
start() {
	log_daemon_msg "Starting ArcLauncher"
	pid=$(arclauncher_pid)
	if [ -n "$pid" ]
	then
	   log_failure_msg "ArcLauncher is already running (pid: $pid)"
	else
           mono-service -l:$ARCLAUNCHER_HOME/ArcLauncher.lock /home/mono/ArcLauncher.exe
	   log_end_msg 0
	fi
	return 0
}

# Funzione di arresto
stop() {
        log_daemon_msg "Stopping ArcLauncher"
        pid=$(arclauncher_pid)
        if [ -n "$pid" ]
        then
	   kill `cat $ARCLAUNCHER_HOME/ArcLauncher.lock`
	   rm -f $ARCLAUNCHER_HOME/ArcLauncher.lock
	   log_end_msg 0
        else
	   log_failure_msg "ArcLauncher is not running"
	fi
	return 0
}

# Gestione comandi
case "$1" in
  start)
        start
        ;;
  stop)
        stop
        ;;
  restart)
	stop
	sleep 3
	start
	;;
  status)
        pid=$(arclauncher_pid)
	if [ -n "$pid" ]
	then
	   log_success_msg "ArcLauncher is running with pid: $pid"
	else
 	   echo "ArcLauncher is not running"
	fi
        ;;
  *)
        echo "Usage: $0 {start|stop|restart|status}"
        exit 1
esac
exit 0


More information about the Mono-list mailing list