stupid_simple_monit.rb
A really stupidly simple process monitoring script.
Don't use this if you have real process monitoring needs, such as god or monit!
The genesis of this was a project that included sidekiq where the sidekiq
process was stopping for some reason, and monit
was not catching the shutdown and respawning it, and offering no indication why. As a stop-gap, we hacked this little ditty up. One of us had a bit of free time, so we played Keith Richards and took the original hack and minimized it to it's essence.
Installation
Add this line to your application's Gemfile:
gem 'stupid-simple-monit'
And then execute:
$ bundle
Or install it yourself as:
$ gem install stupid-simple-monit
Configuration
Create a configuration file that contains the info needed to find the PID of your running process, and a shell command to respawn the process:
pidfile: path/to/pidfile
start_script: "shell command to respawn your process"
Usage
The command is pretty simple:
$ stupid_simple_monit.rb [CONFIG_FILE]
If you omit CONFIG_FILE
it defaults to ./config.yml
.
Ideally, put this into a crontab
to run, say, every 5 or 10 minutes. (Again that caveat if you need something real, use god
or monit
.)
Contributing
- Fork it ( https://github.com/tamouse/stupid-simple-monit/fork )
- Create your feature branch (
git checkout -b my-new-feature
) - Commit your changes (
git commit -am 'Add some feature'
) - Push to the branch (
git push origin my-new-feature
) - Create a new Pull Request