Created
August 24, 2011 06:41
-
-
Save releu/1167435 to your computer and use it in GitHub Desktop.
thin init.d
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: thin | |
# Required-Start: $local_fs $remote_fs | |
# Required-Stop: $local_fs $remote_fs | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: S 0 1 6 | |
# Short-Description: thin initscript | |
# Description: thin | |
### END INIT INFO | |
# Original author: Forrest Robertson | |
DAEMONS_PATH=/home/user/.rvm/bin | |
APPS=(app1 app2) | |
THIN_CONFIGS=/etc/thin | |
execute_thin() { | |
for i in "${APPS[@]}" | |
do | |
cd "/var/www/apps/${i}/current" && sudo -u user "${DAEMONS_PATH}/${i}_bundle" exec "thin ${1} -C ${THIN_CONFIGS}/${i}.yml" | |
done | |
} | |
case "$1" in | |
start) | |
execute_thin start | |
;; | |
stop) | |
execute_thin stop | |
;; | |
restart) | |
execute_thin stop | |
execute_thin start | |
;; | |
*) | |
echo "Usage: $SCRIPT_NAME {start|stop|restart}" >&2 | |
exit 3 | |
;; | |
esac |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment