Skip to content

Instantly share code, notes, and snippets.

@tomas-stefano
Created January 10, 2013 20:34
Show Gist options
  • Save tomas-stefano/4505554 to your computer and use it in GitHub Desktop.
Save tomas-stefano/4505554 to your computer and use it in GitHub Desktop.
Init script in a debian package with god
#! /bin/sh
### BEGIN INIT INFO
# Provides: my-app
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: My app package
### END INIT INFO
set -e
PATH=/bin:/usr/bin:/sbin:/usr/sbin
APP_ROOT=/var/www/my-app
NAME=myapp-name
action="$1"
GOD="bundle exec god -p 17173"
set -u
case $action in
start)
echo -n "Starting $NAME..."
set -x
if (cd $APP_ROOT && $GOD -c $APP_ROOT/deploy/config.god)
then
echo "$NAME started"
else
echo "failed"
fi
;;
stop)
echo -n "Stopping $NAME..."
if (cd $APP_ROOT && $GOD terminate)
then
echo "$NAME stopped."
else
echo "failed!"
fi
;;
restart)
echo $0
$0 stop
sleep 1
$0 start
;;
*)
echo "Usage: /etc/init.d/$NAME {start|stop|restart}" >&2
exit 1
;;
esac
exit 0
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment