-
-
Save jodoherty/3962e20d5e92b4b0f776 to your computer and use it in GitHub Desktop.
SysV init script for a passenger standalone Rails application
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 | |
# Required-Start: $network $local_fs | |
# Required-Stop: | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: Rails application | |
# Description: Rails application | |
### END INIT INFO | |
NAME=app | |
USER=deployer | |
DEPLOY_DIR="/home/${USER}/${NAME}" | |
CMD="/home/${USER}/.rvm/wrappers/${NAME}/passenger" | |
TEMP_DIR="${DEPLOY_DIR}/tmp" | |
PORT=3000 | |
PID_FILE="${TEMP_DIR}/pids/passenger.${PORT}.pid" | |
LOG_FILE="${DEPLOY_DIR}/log/passenger.${PORT}.log" | |
. /etc/${NAME}/env | |
start () { | |
$CMD start $DEPLOY_DIR \ | |
--log-file $LOG_FILE \ | |
--temp-dir $TEMP_DIR \ | |
--pid-file $PID_FILE \ | |
-d -e production --user $USER | |
} | |
stop () { | |
$CMD stop --pid-file $PID_FILE | |
} | |
status () { | |
$CMD status --pid-file $PID_FILE | |
} | |
restart () { | |
stop | |
sleep 1 | |
start | |
} | |
case "$1" in | |
start) | |
start | |
;; | |
stop) | |
stop | |
;; | |
status) | |
status | |
;; | |
restart) | |
restart | |
;; | |
*) | |
echo "Usage: $0 {start|stop|status|restart}" | |
exit 1 | |
esac | |
exit $RETVAL | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
I had to use this when deploying on a Debian 7 VPS sitting behind haproxy.