[Mono-list] Re: mono-service

Robert Jordan robertj at gmx.net
Tue Nov 1 06:44:13 EST 2005


Peter,

> Could I take the opportunity to add my voice to this?  I was intending
> to post something similar when I'd done a bit more work on the topic,
> but Wilson has beaten me to it.
> 
> The mono-service man pages are very sparse.  If I can get it working,
> I'd be very happy to write it up as a How-To sort of document for
> others.

Would you please elaborate? Which part of "man mono-service" is unclear
or sparse?

The only thing I can say about it: it doesn't mention that stdout
is redirected to /dev/null, but is how daemons have to behave on unix.
You can always use Console.Error.WriteLine ...

I'm attaching a init.d skeleton for mono-services, in the hope
that this (not quite mono related) problem will settle down
for a while.

It's for SUSE, but it can be easily adapted to other distros.

Robert
-------------- next part --------------
#!/bin/sh

### BEGIN INIT INFO
# Provides:          monoservice
# Required-Start:    $network
# Required-Stop:
# Default-Start:     3 5
# Default-Stop:      0 1 2 6
# Short-Description: monoservice daemon
# Description:       monoservice daemon
### END INIT INFO


# configure this
SERVICE_DRIVER=/usr/bin/mono-service
# configure this as well
SERVICE_ASSEMBLY=/path/to/assembly.exe


SERVICE_NAME=`basename $SERVICE_ASSEMBLY .exe`
SERVICE_LOCK=/var/run/${SERVICE_NAME}.pid

. /etc/rc.status
rc_reset

case "$1" in
    start)
        echo -n "Starting Mono Service $SERVICE_NAME "
        $SERVICE_DRIVER -l:$SERVICE_LOCK $SERVICE_ASSEMBLY
        rc_status -v
        ;;
    stop)
        echo -n "Shutting down Mono Service $SERVICE_NAME "
	test -f $SERVICE_LOCK && kill `cat $SERVICE_LOCK`
        rc_status -v
        ;;
    restart)
        $0 stop
        $0 start
        rc_status
        ;;
    reload)
        rc_failed 3
        rc_status -v
        ;;
    status)
        echo -n "Checking for Mono Service $SERVICE_NAME "
	test -f $SERVICE_LOCK
        rc_status -v
        ;;
    pause)
	echo -n "Pausing Mono Service $SERVICE_NAME "
	test -f $SERVICE_LOCK && kill -USR1 `cat $SERVICE_LOCK`
        rc_status -v
	;;
    resume)
	echo -n "Resuming Mono Service $SERVICE_NAME "
	test -f $SERVICE_LOCK && kill -USR2 `cat $SERVICE_LOCK`
        rc_status -v
	;;
    *)
        echo "Usage: $0 {start|stop|status|restart|reload}"
        exit 1
        ;;
esac

rc_exit


More information about the Mono-list mailing list