Created
September 19, 2013 08:24
Shell script to start a daemon.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/sh | |
NAME="[ TEST DAEMON ]" | |
PID="./test_daemon.pid" | |
CMD="ruby test_daemon.rb" | |
start() | |
{ | |
if [ -e $PID ]; then | |
echo "$NAME already started" | |
exit 1 | |
fi | |
echo "$NAME START!" | |
$CMD | |
} | |
stop() | |
{ | |
if [ ! -e $PID ]; then | |
echo "$NAME not started" | |
exit 1 | |
fi | |
echo "$NAME STOP!" | |
kill -INT `cat ${PID}` | |
rm $PID | |
} | |
restart() | |
{ | |
stop | |
sleep 2 | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo "Syntax Error: release [start|stop|restart]" | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment