4
# Required-Start: $local_fs $remote_fs
5
# Required-Stop: $local_fs $remote_fs
6
# Default-Start: 2 3 4 5
8
# Short-Description: unicorn initscript
15
DESC="Unicorn web server"
17
. /lib/lsb/init-functions
19
if [ -f /etc/default/unicorn ]; then
20
. /etc/default/unicorn
23
DAEMON=/usr/bin/unicorn
24
PID=${PID-/run/unicorn.pid}
27
([ "${previous-}" ] && [ "${runlevel-}" ]) || [ "${runlevel-}" = S ]
31
if ! run_by_init; then
32
log_action_msg "$1 Not starting."
38
if [ $CONFIGURED != "yes" ]; then
39
exit_with_message "Unicorn is not configured (see /etc/default/unicorn)."
44
if ! [ -d $APP_ROOT ]; then
45
exit_with_message "Application directory $APP_ROOT is not exist."
56
log_daemon_msg "Starting $DESC" $NAME || true
57
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $UNICORN_OPTS; then
64
log_daemon_msg "Stopping $DESC" $NAME || true
65
if start-stop-daemon --stop --signal QUIT --quiet --oknodo --pidfile $PID; then
72
log_daemon_msg "Forcing stop of $DESC" $NAME || true
73
if start-stop-daemon --stop --quiet --oknodo --pidfile $PID; then
80
log_daemon_msg "Restarting $DESC" $NAME || true
81
start-stop-daemon --stop --quiet --oknodo --pidfile $PID
83
if start-stop-daemon --start --quiet --oknodo --pidfile $PID --exec $DAEMON -- $UNICORN_OPTS; then
90
log_daemon_msg "Reloading $DESC" $NAME || true
91
if start-stop-daemon --stop --signal HUP --quiet --oknodo --pidfile $PID; then
98
log_daemon_msg "Relopening log files of $DESC" $NAME || true
99
if start-stop-daemon --stop --signal USR1 --quiet --oknodo --pidfile $PID; then
100
log_end_msg 0 || true
102
log_end_msg 1 || true
106
status_of_proc -p $PID $DAEMON $NAME && exit 0 || exit $?
109
log_action_msg "Usage: $0 <start|stop|restart|force-reload|reload|force-stop|reopen-logs|status>" || true