Skip to content

Instantly share code, notes, and snippets.

@bencates
Forked from sorah/thin
Last active December 20, 2015 02:19
Show Gist options
  • Save bencates/6055305 to your computer and use it in GitHub Desktop.
Save bencates/6055305 to your computer and use it in GitHub Desktop.
#!/bin/bash
CURRENT_DIR=/home/
DAEMON=$CURRENT_DIR/bin/thin
CONFIG=$CURRENT_DIR/config/thin.yml
SCRIPT_NAME=/etc/init.d/thin
# Exit if the package is not installed
[ -x "$DAEMON" ] || exit 0
invoke()
{
echo "[$1] $CONFIG"
cd `grep "^chdir: " $CONFIG|sed -e 's/^chdir: //g'`
[ -d "./log" ] && chown `grep "^user: " $CONFIG|sed -e 's/^user: //g'` ./log
chown -R `grep "^user: " $CONFIG|sed -e 's/^user: //g'` ./tmp/pids
chgrp -R `grep "^group: " $CONFIG|sed -e 's/^group: //g'` ./tmp/pids
$DAEMON $1 -d --config=$CONFIG
}
case "$1" in
start)
invoke start $2
;;
stop)
invoke stop $2
;;
restart)
invoke restart $2
;;
*)
echo "Usage: $SCRIPT_NAME {start|stop|restart} [config_name]" >&2
exit 3
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment