-
-
Save dejan-stankovic/2d7465478f34513c3bff to your computer and use it in GitHub Desktop.
unicorn init 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/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 |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment