[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Demexp-dev] Writing /etc/init.d script to launch demexp
From: |
David MENTRE |
Subject: |
Re: [Demexp-dev] Writing /etc/init.d script to launch demexp |
Date: |
Wed, 19 Apr 2006 21:12:56 +0200 |
User-agent: |
Gnus/5.1006 (Gnus v5.10.6) Emacs/21.4 (gnu/linux) |
David MENTRE <address@hidden> writes:
> Here is a first try. Paths in the script are obviously wrong (one should
> use /var/log/demexp and /var/demexp/) but the general idea is here.
Another thing I would like is to launch demexp under a specific user. Is
doing a "su properuser" in start() enough?
I join latest version of the script that prints proper messages on the
console.
#!/bin/sh
DEMEXP_BIN=/home/david/pub/expdem/demexp--dev--0.7/srv/demexp-server
DEMEXP_OPTIONS=""
DEMEXP_LOG_DIR=/tmp
DEMEXP_BASES_DIR=/tmp
DEMEXP_LISTEN_ADDRESS=localhost:50000
# don't execute this script if no binary
test -x $DEMEXP_BIN || exit 0
# where to put our logs?
log_filename=$DEMEXP_LOG_DIR/demexp-`date -Iseconds`
# where are our bases?
bases=$DEMEXP_BASES_DIR/bases.dmxp
pid_file=$DEMEXP_BASES_DIR/bases.pid
start() {
$DEMEXP_BIN $DEMEXP_OPTIONS \
--daemon --bases $bases --listen $DEMEXP_LISTEN_ADDRESS \
--logfile $log_filename.log 2> $log_filename.err &
return $?
}
stop() {
kill -SIGQUIT `cat $pid_file`
return $?
}
case "$1" in
start)
echo -n "Starting demexp server:"
start
;;
stop)
echo -n "Stopping demexp server:"
stop
;;
restart)
echo -n "Restarting demexp server:"
stop
if [ $? -eq 0 ]; then
sleep 8 # hardcoded in server, 7s + 1s of margin
start
fi
;;
reload|force-reload)
;;
esac
if [ $? -eq 0 ]; then
echo " done."
exit 0
else
echo " failed"
exit 1
fi
Best wishes,
d.
--
address@hidden