Created
January 31, 2013 21:45
-
-
Save ebarendt/4686808 to your computer and use it in GitHub Desktop.
start-stop-daemon init script for starting passenger
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: app_name | |
# Required-Start: $network $remote_fs $syslog | |
# Required-Stop: $network $remote_fs $syslog | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: start the app_name application | |
### END INIT INFO | |
APP="<%= current_path %>" | |
PASSENGER="/usr/local/bin/passenger" | |
PORT=3000 | |
ENVIRONMENT=<%= rails_env %> | |
USER=<%= user %> | |
export PIDFILE=<%= shared_path %>/pids/passenger.$PORT.pid | |
ARGS="start $APP --log-file <%= shared_path %>/log/passenger.$PORT.log --pid-file $PIDFILE --user $USER -p $PORT -e $ENVIRONMENT -d" | |
. /lib/lsb/init-functions | |
case "$1" in | |
start) | |
log_daemon_msg "Starting the AppName server" "app_name" | |
start-stop-daemon --start --quiet --oknodo --exec $PASSENGER -- $ARGS | |
log_end_msg $? | |
;; | |
stop) | |
log_daemon_msg "Stopping the AppName server" "app_name" | |
start-stop-daemon --stop --quiet --oknodo -p $PIDFILE | |
log_end_msg $? | |
;; | |
restart|force-reload) | |
$0 stop && sleep 2 && $0 start | |
;; | |
status) | |
status_of_proc -p $PIDFILE $PASSENGER app_name && exit 0 || exit $? | |
;; | |
*) | |
echo "Usage: /etc/init.d/app_name {start|stop|restart|force-reload|status}" | |
exit 1 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment