Created
December 7, 2011 23:23
-
-
Save lorn/1445260 to your computer and use it in GitHub Desktop.
Starman init.d script
This file contains hidden or 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/bash | |
# starman - this script starts and stops the starman daemon | |
# | |
# chkconfig: - 85 15 | |
# description: Starman | |
# processname: starman | |
# pidfile : /var/run/starman.pid | |
# www file: /var/www/myapp | |
# Source function library. | |
. /etc/rc.d/init.d/functions | |
export starman="/usr/bin/starman" | |
export myapp_path="/var/www/myapp" | |
export pidfile="/var/run/starman.pid" | |
start() { | |
echo -n $"Starting Starman: " | |
$starman -I${myapp_path}/lib --user=nginx --listen :8080 --listen /var/run/nginx/starman.sock --daemonize --pid ${pidfile} --error-log /var/log/nginx/starman.log ${myapp_path}/${myapp}.psgi | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] | |
return $RETVAL | |
} | |
restart() { | |
echo -n $"Restarting Starman: " | |
export PID=`cat ${pidfile}` | |
kill -s USR2 $PID | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] | |
return $RETVAL | |
} | |
stop() { | |
echo -n $"Stopping Starman: " | |
killproc -p ${pidfile} -d 10 $starman | |
RETVAL=$? | |
echo | |
[ $RETVAL = 0 ] && rm -f ${pidfile} | |
} | |
# See how we were called. | |
case "$1" in | |
start) | |
start | |
;; | |
restart) | |
restart | |
;; | |
stop) | |
stop | |
;; | |
*) | |
echo $"Usage: starman {start|restart|stop}" | |
exit 1 | |
esac | |
exit $RETVAL |
And sticking with the init script approach, this uses Server::Starter for graceful restarts:
https://github.com/mla/starman-init
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For a more comprehensive solution, might want to take a look at starmachine: https://github.com/solgenomics/starmachine