Skip to content

Instantly share code, notes, and snippets.

@nessamurmur
Last active December 24, 2015 02:19
Show Gist options
  • Save nessamurmur/6730347 to your computer and use it in GitHub Desktop.
Save nessamurmur/6730347 to your computer and use it in GitHub Desktop.
Basic monit example
check process unicorn
with pidfile /path/to/pid/unicorn.pid
start program = "/sbin/service unicorn start" with timeout 120 seconds
stop program = "/sbin/service unicorn stop"
if totalmem is greater than 500 MB for 2 cycles then restart
@nessamurmur
Copy link
Author

  1. Define the process you want monit to monitor, in this case we'll call the process unicorn. This will let you run:
sudo monit start unicorn
sudo monit restart unicorn
sudo monit stop unicorn
  1. Next tell monit where to find the process id to know a process is running.
  2. Next, feed unicorn the command to run to start the service. You can add options like "with timeout 120 seconds" or "as uid unprivileged_user"
  3. Tell monit how to stop the program.
  4. You can add other conditionals like this one to restart the process if it starts eating too much memory.

@nessamurmur
Copy link
Author

This file lives in /etc/monit.d/ by default.

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