Skip to content

Instantly share code, notes, and snippets.

@mariuz
Created April 4, 2014 11:54
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mariuz/9972993 to your computer and use it in GitHub Desktop.
Save mariuz/9972993 to your computer and use it in GitHub Desktop.
unicorn init script for a system wide rvm (app runs under ubuntu user and is configured with pid in tmp, can be tweaked)
#!/bin/sh
### BEGIN INIT INFO
# Provides: unicorn
# 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: unicorn initscript
# Description: unicorn
### END INIT INFO
# start the app
cd /home/ubuntu/app
SCRIPT_NAME=/etc/init.d/unicorn
case "$1" in
start)
sudo su -c "source '/usr/local/rvm/scripts/rvm'; unicorn -c config/unicorn.rb -D -E production" ubuntu
;;
stop)
sudo su -c "kill -s QUIT `cat /tmp/unicorn.pid`" ubuntu
;;
restart)
stop
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