start/stop scripts
When writing start/stop scripts, halockrun provides two very valueable features:
- Reliable, injected PID files
- Synchronization possibilities
Reliable, injected PID file means that the PID file can not become stale and that the process itself doesn't need to do anything for that.
#! /bin/sh
PROGRAM_NAME="sleep"
START_COMMAND="sleep 1000000"
SIGNAL1="TERM"
SLEEP1="5"
SIGNAL2="KILL"
LOCKFILE=/tmp/MyLockFile
case "$1" in
'start')
./halockrun -anc -E 42
if [ $? -eq 42 ]; then
PROGRAM_PID=$(halockrun -t )
echo " is already running with PID "
fi
;;
'stop')
PROGRAM_PID=$(halockrun -t )
if [ $? -eq 0 ]; then
echo " is not running"
else
echo "Terminating () with ..."
kill -
halockrun -cn echo " () terminated"
if [ $? -eq 99 ]; then
sleep
echo "Terminating () with ..."
kill -
halockrun -cn echo " () terminated"
if [ $? -eq 99 ]; then
sleep
halockrun -cn echo " () terminated"
if [ $? -eq 99 ]; then
echo " () has not terminated."
fi
fi
fi
fi
;;
'status')
PROGRAM_PID=$(halockrun -t )
if [ $? = 0 ]; then
echo " is not running"
else
echo " is running with PID "
fi
;;
*)
echo "usage: $0 start|stop|status"
;;
esac


