So this year I finally got a chance to participate in Rails Rumble.
I partnered up with Sohaib Bhatti and after some brief brainstorming we decided on building out a Twitter based downtime notification system.
The idea consists of a Web Service that listens to the Twitter stream looking for a particular trigger hashtag.
Once it detects a trigger tweet, it pulls out the URL included in the tweet and hits the url and checks to see if the endpoint is reachable. If it is, it tracks the http status code retrieved (e.g. 200, 404, 500 etc...) and takes a screenshot of the url. It then replies to the Twitter user with the status and the screenshot (if available).
Obviously, being a Rails Rumble entry, the app was built on Ruby and Rails 4 specifically.
The app itself consists of 3 main components:
- Twitter Stream Monitor (long running rake task)
- URL Tester Sidekiq Worker
- Rails Web App
Twitter Stream Monitor
We setup the Twitter monitor as a long running rake task. We're using this Twitter gem to tap into the Twitter streaming API with the filter configured for our chosen "trigger" hashtag. The rake test fires off Sidekiq jobs that actually do the URL testing work.
So Sidekiq is pretty awesome. We use Sidekiq to do most of the heavy lifting. The worker fires up Phantomjs which renders the webpage, uploads the image to S3 and then uses the Twitter Rest API to reply to the original user.
Rails Web App
The Rails App displays a paginated list of the downtime test history, including the screenshot, URL and status.
It was great fun taking part in Rails Rumble 2014 and I'm really happy with how the project turned out. We just about managed to get everything up and running before the deadline. Looking forward to the next one!