我如何安装 xsp 作为守护进程运行。我运行/etc/init.d/xsp
脚本(见下文)它停止并显示状态消息:
Listening on address: 0.0.0.0
Root directory: /var/www/asptest
Listening on port: 8080 (non-secure)
Hit Return to stop the server.
我认为我的 Linux AMI 基于 Redhat/Centos,因此其中没有 start-stop-daemon 实用程序。这是我的
/etc/init.d/xsp
脚本:
#!/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
任何帮助均感激不尽。