#! /bin/sh ### BEGIN INIT INFO # Provides: <%= node[:app_name] %> # Required-Start: $all # Required-Stop: $all # Default-Start: 2 3 4 5 # Default-Stop: 0 1 6 # Short-Description: starts the unicorn server for <%= node[:app_name] %> # Description: starts unicorn server for <%= node[:app_name] %> using start-stop-daemon ### END INIT INFO NAME="<%= node[:app_name] %>" DESC="unicorn for $NAME" PATH=/usr/local/sbin:/usr/local/bin:/sbin:/bin:/usr/sbin:/usr/bin DAEMON="<%= File.join(node[:project_dir], node[:app_dir], "libexec", "unicorn_root") %>" PIDFILE="<%= File.join(node[:project_dir], node[:run_dir], "unicorn.pid") %>" set -e . /lib/lsb/init-functions case "$1" in start) echo -n "Starting $DESC: " start-stop-daemon --start --quiet --pidfile $PIDFILE \ --exec $DAEMON start || true echo "$NAME." ;; stop) echo -n "Stopping $DESC: " kill -TERM $(cat $PIDFILE) || true echo "$NAME." ;; restart|force-reload) echo -n "Restarting $DESC: " kill -TERM $(cat $PIDFILE) || true sleep 1 start-stop-daemon --start --quiet --pidfile $PIDFILE \ --exec $DAEMON start || true echo "$NAME." ;; reload) echo -n "Reloading $DESC configuration: " kill -USR2 $(cat $PIDFILE) || true echo "$NAME." ;; status) status_of_proc -p $PIDFILE "$DAEMON" $NAME && exit 0 || exit $? ;; *) N=/etc/init.d/$NAME echo "Usage: $N {start|stop|restart|reload|force-reload|status}" >&2 exit 1 ;; esac exit 0