Skip to content

Instantly share code, notes, and snippets.

@garthk
Last active December 11, 2015 23:58
Show Gist options
  • Save garthk/4680681 to your computer and use it in GitHub Desktop.
Save garthk/4680681 to your computer and use it in GitHub Desktop.
`init.d` script for Puppet Dashboard worker processes.
#!/bin/sh
### BEGIN INIT INFO
# Provides: dashboard-workers
# Required-Start: $remote_fs $syslog
# Required-Stop: $remote_fs $syslog
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: dashboard workers
# Description: Start dashboard-workers daemon placed in /etc/init.d.
### END INIT INFO
SCRIPTNAME=/etc/init.d/dashboard-workers
case "$1" in
start)
;;
stop)
;;
status)
STOPCOUNT=$(/bin/su dashboard -s /bin/sh -c "/usr/bin/env RAILS_ENV=production /usr/share/puppet-dashboard/script/delayed_job -p dashboard -n 4 -m status" | grep "no instances" | wc -l)
case $STOPCOUNT in
0)
echo running
exit 0
;;
*)
echo not running
exit 3
;;
esac
;;
restart)
;;
*)
echo "Usage: $SCRIPTNAME {start|stop|status|restart}" >&2
exit 3
;;
esac
@garthk
Copy link
Author

garthk commented Jan 31, 2013

To install:

  • Copy script to /etc/init.d/dashboard-workers
  • puppet resource service dashboard-workers enable=true ensure=running

Please accept my apology for the ghastly hack on status; delayed_job doesn't give a helpful exit status.

Better yet, please improve the script. :)

@garthk
Copy link
Author

garthk commented Jan 31, 2013

Well, huh. The Puppet Labs APT repo .deb for puppet-dashboard includes an init.d script, but it doesn't end up deployed on my systems. Investigating…

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment