Norbert
Visitor
|
Palabre 0.3 - Startup Script - 2005/11/19 23:28
The following startup script may be useful to run Palabre 0.3 in daemon mode. Based on a shoutcast startup script that I found at
http://www.seebq.com/projects/shoutcast
I'm now using Palabre in a production environment at http://www.sunsetbeachbar.com/livecam - looks excellent so far.
Thanks!!!!
| Code: |
#!/usr/local/bin/bash
#
# description: Starts and stops Palabre Chat Server.
#
# binaries in /usr/local/palabre-0.3
# log in /var/log
#
#
stop (){
#First we want to kill the original servers, so we don't get errors.
echo "Killing old palabre server."
for oldpid in `ps -U nobody | grep PalabreStart.py | cut -c 1-7`; do
kill $oldpid
if [[ $1 == "-v" ]]
then
echo 'Killed: '$oldpid
fi
done
rm -f /var/run/shoutcast.pid
}
start (){
#Now we can start the servers up.
if [[ $2 == "-v" ]]
then
echo "Starting up the new Palabre server..."
fi
sudo -u nobody nohup python /usr/local/palabre-0.3/PalabreStart.py >> /
usr/local/palabre-0.3/palabre.log &
#Create the pid file...
ps -A | grep PalabreStart.py | cut -c 1-7 > /var/run/palabre.pid
#Done now!
}
case "$1" in
start)
if [[ ! -e /var/run/palabre.pid ]]
then
start $2
if [[ -e /var/run/palabre.pid ]]
then
echo "Startup [SUCCESS]"
fi
else
if [[ $2 == "-v" ]]
then
echo "Palabre is already running these processes:"
#Toldja! Checks before displaying pid file.
if [[ -e /var/run/palabre.pid ]]
then
cat /var/run/palabre.pid
fi
echo "Try calling palabrectl restart in order to kill old processes."
else
echo "palabre is already running. Try calling palabrectl restart."
fi
echo "Startup [FAILED]"
fi
;;
restart)
stop $2
if [[ $2 == "-v" ]]
then
echo "Waiting for the old servers to die..."
fi
sleep 4
start $2
if [[ -e /var/run/palabre.pid ]]
then
echo "Startup [SUCCESS]"
fi
;;
stop)
if [[ -e /var/run/palabre.pid ]];
then
stop $2
echo "Palabre shutdown [SUCCESS]"
else
echo "There are no registered palabre servers running right now. Attempting to kill anyways."
stop $2
fi
;;
*)
echo "Usage: palabrectl (start|stop|restart) [-v]"
esac
|
|