Skip to content

Instantly share code, notes, and snippets.

@lorn
Created December 7, 2011 23:23
Show Gist options
  • Save lorn/1445260 to your computer and use it in GitHub Desktop.
Save lorn/1445260 to your computer and use it in GitHub Desktop.
Starman init.d script
#!/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
@rbuels
Copy link

rbuels commented Feb 18, 2013

For a more comprehensive solution, might want to take a look at starmachine: https://github.com/solgenomics/starmachine

@mla
Copy link

mla commented Jul 7, 2014

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