Take the 2-minute tour ×
Super User is a question and answer site for computer enthusiasts and power users. It's 100% free, no registration required.

How can I install xsp to run as a daemon.I run my /etc/init.d/xsp script(see below) it stops with status message :

Listening on address: 0.0.0.0
Root directory: /var/www/asptest
Listening on port: 8080 (non-secure)
Hit Return to stop the server.

I think my Linux AMI is based on Redhat/Centos so there is no start-stop-daemon util in it.. Here is my /etc/init.d/xsp script:

#!/bin/sh
### BEGIN INIT INFO
# Provides:          xsp
# Required-Start:    $local_fs $remote_fs $network
# Required-Stop:     $local_fs $remote_fs $network
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Asp.Net testing server startup script.
# Description:       Asp.Net testing server startup script.
### END INIT INFO

PATH=/sbin:/usr/sbin:/bin:/usr/bin
DESC=xsp
NAME=xsp
DAEMON=/usr/bin/xsp4
DEFAULT=/etc/default/$NAME
DAEMON_ARGS="--nonstop --root /var/www/asptest"
#DAEMON_ARGS="--nonstop --root /usr/lib/xsp/test"
MONO_SHARED_DIR=/var/run/$NAME
PIDFILE=/var/run/$NAME.pid
SCRIPTNAME=/etc/init.d/$NAME

[ -x "$DAEMON" ] || exit 0
[ -f "$DEFAULT" ] && . $DEFAULT

. /lib/lsb/init-functions

if [ ! -e $MONO_SHARED_DIR ]; then
        mkdir $MONO_SHARED_DIR
    chown $user:$group $MONO_SHARED_DIR
fi

chk_start() {
        if [ -f "$PIDFILE" ]; then
                xpid=`head -1 "$PIDFILE"`
                xps=`ps -p $xpid | wc -l`
                if [ "$xps" != "1" ]; then
                        echo -n "Xsp is running"
                        return 1
                fi
        fi
        return 0
}

do_start()
{
        export MONO_SHARED_DIR
        daemon --user $USER --pidfile /var/run/${NAME}.pid $DAEMON --port $port --address $address $DAEMON_ARGS &
}

do_stop()
{
        if [ -e "$PIDFILE" ] ; then
                kill -9 `head -1 "$PIDFILE"` 1>/dev/null 2>&1
            rm -f "$PIDFILE"
        fi
}

case "$1" in
  start)
        if chk_start ; then
                do_start
        fi
        ;;
  stop)
        do_stop
        ;;
  status)
       ;;
  restart|force-reload)
        do_stop
        do_start
        ;;
  *)
        echo "Usage: $SCRIPTNAME {start|stop|status|restart|force-reload}" >&2
        exit 3
        ;;
esac

Any help appreciated.

share|improve this question
add comment

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Browse other questions tagged or ask your own question.