[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
RE: mzscheme daemon?
On Dec 5, Anton van Straaten wrote:
> Thanks - that's probably fine, I just don't know enough about it. I
> ran into trouble when I tested starting mzscheme in the background
> from a shell prompt - when I logged out, the task was automatically
> terminated. I realize now that this might have been because I
> didn't think to redirect the i/o, so it was probably terminating
> when it lost that.
So, for the sake of completeness I wanted to include the
/etc/rc.d/init.d/scheme-webserver -- so I cleaned it and this is a
version that works by itself (the previous script was there so the
init script will start it with the stadard init functions...).
----------------------------------------------------------------------
#!/bin/bash
#
# Startup script for Eli's Scheme Web Server
#
# chkconfig: - 85 15
# description: Eli's Scheme server.
# processname: mzscheme
# pidfile: /var/run/scheme-webserver-daemon.pid
# Source function library.
. /etc/rc.d/init.d/functions
prog=scheme-webserver
pidfile=/var/run/$prog.pid
sysfile=/var/lock/subsys/httpd
RETVAL=0
start() {
echo -n "Starting $prog: "
if [ -f $pidfile -o -f $sysfile ]; then
echo -n "pid file or subsys locked"
echo_failure
echo
return 1
fi
cd /home/eli/scheme/webserver
/home/eli/bin/mzscheme \
-mf /home/eli/scheme/webserver/server -e -start- -- \
`hostname` '80' < /dev/null > /tmp/webserver-log 2>&1 &
echo $! > $pidfile
# Assume that it always succeeds
RETVAL=0
echo_success
echo
touch $sysfile
return 0
}
stop() {
echo -n "Stopping $prog: "
killproc $prog
RETVAL=$?
echo
[ $RETVAL = 0 ] && rm -f $pidfile $sysfile
}
status() {
if [ -f $pidfile ]; then
read pid < $pidfile
if [ "$pid" = "" ] ; then
echo "$pidfile is empty"
return 1
elif ps $pid > /dev/null 2>&1; then
echo "$prog (pid $pid) is running..."
return 0
else
echo "$prog dead but pid file exists ($pidfile)"
return 1
fi
fi
if [ -f $sysfile ]; then
echo "$prog dead but subsys locked ($sysfile)"
return 2
fi
echo "$prog is stopped"
return 3
}
# See how we were called.
case "$1" in
start)
start
;;
stop)
stop
;;
status)
status
RETVAL=$?
;;
condrestart)
if [ -f $pidfile ]; then
stop
start
fi
;;
restart)
stop
start
;;
*)
echo "Usage: $prog {start|stop|status|condrestart|restart}"
exit 1
esac
exit $RETVAL
----------------------------------------------------------------------
--
((lambda (x) (x x)) (lambda (x) (x x))) Eli Barzilay:
http://www.barzilay.org/ Maze is Life!