Pulse is a Sinatra application that can be used to check to see if a website is currently up or down and then send you a Text message to alert of its change in status.
Start application with:
$ git clone git://github.com/AndrewGertig/pulse.git
$ cd pulse
$ bundle
$ createdb yourappname
Using Foreman, .env, and a Procfile
$ foreman start
To access and change data via the console
$ irb
$ require './app.rb'
Create your first Site
$ Site.create(url: "http://andrewgertig.com")
Open your browser to whichever PORT you are using, (for me I have it set to PORT=5002 in my .env file so http://localhost:5002) and you should see something like this:
Green means the site is up, Red means it's down. I used to own two.io but couldn't ever figure out what to do with it 😞
- Get a Twilio SMS account
- Add your phone number and keys to your .env file
- Add your Twilio keys to Heroku config
$ heroku config:add MY_TWILIO_NUM=5558675309 TWILIO_ACCOUNT_SID=XXXXXXXXXSIDXXXXXXXX TWILIO_ACCOUNT_TOKEN=XXXXXXXXTOKENXXXXXXXX
If you want emails to be sent, configure SendGrid.
- Run
heroku addons:add sendgrid:starter
- Set your email address
ENV
variable:heroku config:add [email protected] [email protected]
If you want emails to be sent by Mandrill by MailChimp setup the Heroku addon like this.
- Run
heroku addons:add mandrill:starter
- Set your email address
ENV
variable:heroku config:add [email protected] [email protected]
In order to check to see if a site is "UP" or "DOWN" you will need to setup a scheduled rake task using Heroku's Scheduler
$ heroku addons:add scheduler:standard
$ heroku addons:open scheduler
Create a Job that runs "rake check_sites" every 10 minutes, it should look like this once you are done:
To use the Datamapper
methods (below), you need to remotely connect to the console on Heroku. To do this, run: heroku run console
then require './app.rb'
Create
$ Site.create(url: "http://andrewgertig.com")
Find
$ Site.get(1)
$ Site.first(:url => "http://andrewgertig.com")
Update
$ Site.get(1).update(url: "http://gertig.com")
Destroy
$ site = Site.get(5)
$ site.destroy # => true