Skip to content

Instantly share code, notes, and snippets.

@releu
Created August 24, 2011 06:41
Show Gist options
  • Save releu/1167435 to your computer and use it in GitHub Desktop.
Save releu/1167435 to your computer and use it in GitHub Desktop.
thin init.d
#!/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