public
Last active

unicorn init script

  • Download Gist
gistfile1.sh
Shell
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63
#!/bin/sh
 
### BEGIN INIT INFO
# Provides: unicorn
# Required-Start: $local_fs $remote_fs $network $syslog
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: starts the unicorn web server
# Description: starts unicorn
### END INIT INFO
 
DAEMON=/usr/local/bin/unicorn_rails
DAEMON_OPTS="-c /path/to/unicorn.conf.rb -E production -D"
NAME=unicorn_rails
DESC=unicorn_rails
PID=/path/to/unicorn.pid
OLDPID="$PID.oldbin"
 
sig () {
test -s "$PID" && kill -$1 `cat $PID`
}
 
oldsig () {
test -s $OLDPID && kill -$1 `cat $OLDPID`
}
 
case "$1" in
start)
echo -n "Starting $DESC: "
$DAEMON $DAEMON_OPTS
echo "$NAME."
;;
stop)
echo -n "Stopping $DESC: "
sig QUIT
echo "$NAME."
;;
restart)
echo -n "Restarting $DESC: "
sig QUIT
sleep 1
$DAEMON $DAEMON_OPTS
echo "$NAME."
;;
reload)
echo -n "Reloading $DESC code: "
sig USR2
echo "$NAME."
;;
reopen-logs)
echo -n "Reopening $DESC logs: "
sig USR1
echo "$NAME."
;;
 
*)
echo "Usage: $NAME {start|stop|restart|reload|reopen-logs}" >&2
exit 1
;;
esac
 
exit 0

Please sign in to comment on this gist.

Something went wrong with that request. Please try again.