Skip to content

Instantly share code, notes, and snippets.

@r3nya
Forked from sasha-id/bluepill
Created October 12, 2013 17:33
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 r3nya/6952660 to your computer and use it in GitHub Desktop.
Save r3nya/6952660 to your computer and use it in GitHub Desktop.
#!/bin/sh
### BEGIN INIT INFO
# Provides: bluepill
# Required-Start: $local_fs $remote_fs $network $syslog $time
# Required-Stop: $local_fs $remote_fs $network $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: bluepill daemon, providing process monitoring
# Description: bluepill is a monitoring tool. More info at http://github.com/arya/bluepill.
### END INIT INFO
set -e
. /lib/lsb/init-functions
# here comes default config
USER=XXXXXXX
RAILS_ENV=production
APP_NAME=XXXXXXXX
APP_ROOT=/u/apps/$APP_NAME
CMD="sudo -i -u $USER -- sh -c 'cd $APP_ROOT/current && RAILS_ENV=$RAILS_ENV bundle exec bluepill --no-privileged -c $APP_ROOT/shared -l $APP_ROOT/shared/log/bluepill.log"
case "$1" in
start)
echo -n "Starting bluepill for user $USER"
eval "$CMD load $APP_ROOT/current/config/bluepill.rb'"
;;
stop)
echo "Shutting down monitored processes"
eval "$CMD stop'"
echo "Shutting down bluepill daemon"
eval "$CMD quit'"
;;
restart)
## Stop the service and regardless of whether it was
## running or not, start it again.
$0 stop
$0 start
;;
status)
eval "$CMD status'"
;;
*)
echo "Usage: $0 {start|stop|restart}"
exit 1
;;
esac
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment