I need a simple ping service which notifies me (via email) when my web application is down. I can write a simple ruby script to achieve that without much problem.
However, I also want this script to be run regularly and hosted on the internet for FREE. the following is my attempt on using Heroku and Heroku's Scheduler add-on.
(Heroku's scheduler can run every 10mins, 1 hour or 1 day)
only 2 files are needed: health_check.rb and Gemfile.
Source Code:
https://gist.github.com/4153156
Directory Structure:
OK, actually 3 files.
- health_check.rb is a ruby script which calls Net::HTTP and sends email using Net::SMTP
- Gemfile is an file which tells Heroku that this is a ruby application
- Gemfile.lock is the file being generated after running bundle install
that's it. go ahead and push it to heroku:
git push heroku master
and then add Heroku Scheduler to your project.
you can do it by logging in to heroku.com or via command line
add a scheduler job with ruby command line:
DONE.
No comments:
Post a Comment