Posts: 846
Threads: 16
Joined: Sep 2006
Reputation:
0
start-stop-daemon is a feature of debian based distros, centOS is redhat based.
Posts: 3
Threads: 0
Joined: May 2008
Reputation:
0
Hi,
reusing pandora server init script, i obtain a babelserver script that not needs start-stop-daemon.
I test it on CentOS 5.1 and seems to work fine.
bye
--------------------------------------------------------------------------------
#!/bin/bash
# Babel Enterprise, startup script
#
# Linux Version (generico)
#
# Configurable path and filenames
BABEL_HOME="/usr/local/etc/babel/babel_server.conf"
BABEL_PID_PATH="/var/run"
BABEL_PID=$BABEL_PID_PATH/babelserver.pid
BABEL_DAEMON=/usr/local/bin/babelserver
# Main script
if [ ! -d "$BABEL_PID_PATH" ]
then
echo "Babel Enterprise cannot write it's PID file in $BABEL_PID_PATH. Please create that directory"
exit
fi
if [ ! -f $BABEL_DAEMON ]
then
echo "Babel Enterprise not found, please check setup and read manual"
exit
fi
case "$1" in
start)
OLD_PATH="`pwd`"
if [ -f $BABEL_PID ]
then
CHECK_PID=`cat $BABEL_PID`
CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "babelserver" | wc -l`
if [ $CHECK_PID_RESULT == 1 ]
then
echo "Babel Enterprise is currently running on this machine with PID ($CHECK_PID). Aborting now..."
exit
fi
fi
$BABEL_DAEMON $BABEL_HOME -D
sleep 1
MYPID=`ps aux | grep "$BABEL_DAEMON" | grep -v grep | tail -1 | awk '{print $2}'`
if [ ! -z "$MYPID" ]
then
echo $MYPID > $BABEL_PID
echo "Babel Enterprise is now running with PID $MYPID"
else
echo "Cannot start Babel Enterprise. Aborted."
fi
cd "$OLD_PATH"
;;
stop)
if [ -f $BABEL_PID ]
then
echo "Stopping Babel Enterprise"
PID_2=`cat $BABEL_PID`
if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'babelserver' `" ]
then
kill `cat $BABEL_PID` 2> /dev/null > /dev/null
fi
rm -f $BABEL_PID
else
echo "Babel Enterprise is not running, cannot stop it."
fi
;;
force-reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: babelserver {start|stop|restart}"
exit 1
esac
Posts: 846
Threads: 16
Joined: Sep 2006
Reputation:
0
You might want to add "nohup" as well.
Posts: 6
Threads: 2
Joined: May 2008
Reputation:
0
Thanks all.. the script with the minor change worked, you do not need the nohup.
#!/bin/bash
# Babel Enterprise, startup script
#
# Linux Version (generico)
#
# Configurable path and filenames
BABEL_HOME="/usr/local/etc/babel/babel_server.conf"
BABEL_PID_PATH="/var/run"
BABEL_PID=$BABEL_PID_PATH/babelserver.pid
BABEL_DAEMON=/usr/local/bin/babelserver
# Main script
if [ ! -d "$BABEL_PID_PATH" ]
then
echo "Babel Enterprise cannot write it's PID file in $BABEL_PID_PATH. Please create that directory"
exit
fi
if [ ! -f $BABEL_DAEMON ]
then
echo "Babel Enterprise not found, please check setup and read manual"
exit
fi
case "$1" in
start)
OLD_PATH="`pwd`"
if [ -f $BABEL_PID ]
then
CHECK_PID=`cat $BABEL_PID`
CHECK_PID_RESULT=`ps aux | grep -v grep | grep "$CHECK_PID" | grep "babelserver" | wc -l`
if [ $CHECK_PID_RESULT == 1 ]
then
echo "Babel Enterprise is currently running on this machine with PID ($CHECK_PID). Aborting now..."
exit
fi
fi
#$BABEL_DAEMON $BABEL_HOME -D
$BABEL_DAEMON -c $BABEL_HOME &
sleep 1
MYPID=`ps aux | grep "$BABEL_DAEMON" | grep -v grep | tail -1 | awk '{print $2}'`
if [ ! -z "$MYPID" ]
then
echo $MYPID > $BABEL_PID
echo "Babel Enterprise is now running with PID $MYPID"
else
echo "Cannot start Babel Enterprise. Aborted."
fi
cd "$OLD_PATH"
;;
stop)
if [ -f $BABEL_PID ]
then
echo "Stopping Babel Enterprise"
PID_2=`cat $BABEL_PID`
if [ ! -z "`ps -F -p $PID_2 | grep -v grep | grep 'babelserver' `" ]
then
kill `cat $BABEL_PID` 2> /dev/null > /dev/null
fi
rm -f $BABEL_PID
else
echo "Babel Enterprise is not running, cannot stop it."
fi
;;
force-reload|restart)
$0 stop
$0 start
;;
*)
echo "Usage: babelserver {start|stop|restart}"
exit 1
esac
Posts: 846
Threads: 16
Joined: Sep 2006
Reputation:
0
I tested it today, it works fine, I'll upload it to the SVN to package it in the next package releases, which are going to be packaged soon, as 2.0 release is about to be announced.