-
-
Save proapi/01bb62be932d1a06c074 to your computer and use it in GitHub Desktop.
Passenger init script #linux #bash #server
This file contains 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/bash | |
### BEGIN INIT INFO | |
# Provides: myapp passenger in standalone | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# X-Interactive: true | |
# Short-Description: Start/stop myapp.com web site | |
### END INIT INFO | |
#PATH=/sbin:/usr/sbin:/bin:/usr/bin | |
PASSENGER="passenger" | |
ADDRESS=127.0.0.1 | |
PORT=5000 | |
ENVIRONMENT=production | |
APP_NAME=myapp | |
APP_DIR="/var/apps/$APP_NAME/current" | |
USER="chris" | |
SET_PATH="cd $APP_DIR" | |
PRE_CMD="" # e.g. "SENDGRID_USERNAME=username" | |
CMD="$SET_PATH; $PRE_CMD $PASSENGER start -a $ADDRESS -p $PORT -e $ENVIRONMENT -d" | |
. /lib/lsb/init-functions | |
case "$1" in | |
start) | |
echo "Starting $APP_NAME passenger" | |
echo "su - $USER -c \"$CMD\"" | |
su - $USER -c "$CMD" | |
;; | |
stop) | |
echo "Stopping $APP_NAME passenger" | |
cd $APP_DIR | |
$PASSENGER stop -p $PORT | |
;; | |
restart) | |
echo "Restarting $APP_NAME passenger" | |
cd $APP_DIR | |
$PASSENGER stop -p $PORT | |
echo "su - $USER -c \"$CMD\"" | |
su - $USER -c "$CMD" | |
;; | |
*) | |
echo "Usage: $0 start|stop" >&2 | |
exit 3 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment