Skip to content

Instantly share code, notes, and snippets.

@nz
Created June 12, 2013 22:52
Show Gist options
  • Save nz/5769833 to your computer and use it in GitHub Desktop.
Save nz/5769833 to your computer and use it in GitHub Desktop.
My typical monit + Upstart combination.
check process foobar with pidfile /var/run/foobar.pid
start program = "/sbin/start foobar"
stop program = "/sbin/stop foobar"
if mem usage > 2%
for 2 cycles
then restart
if failed host 127.0.0.1 port 8000 protocol HTTP
request /
timeout 20 second
then restart
if 2 restarts within 30 cycles then alert
description "foobar"
start on filesystem or runlevel [2345]
stop on runlevel [!2345]
respawn
respawn limit 10 5
# hack to create a pid file for monit, for mem and pid checks
post-start script
echo `status foobar | sed 's/.*process //'` > /var/run/foobar.pid
end script
exec /var/apps/foobar/current/bin/foobar
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment