I’m StillAlive (and so is my AppHarbor site) – site monitoring made awesome

As many of you know by now, I’m particularly fond of AppHarbor. They continue to provide a totally awesome integrated CI and hosting environment, continue to offer a means of taking the service up for free (as well as recently adding some commercial offerings), and most importantly to this post, they still have a great selection of very cool add-ons.

One of those add-ons is StillAlive which is awesome for two reasons: Firstly, it’s a local Aussie company and secondly, it actually provides a very valuable service that’s going to help me address a niggling problem with ASafaWeb running on AppHarbor.

It’s broken – and I’m the last to know about it

I got up yesterday morning and checked the stats of scans run against ASafaWeb. All was good until 3am and then…. nothing. No more scans were running. This is a report I could load up through the administration interface so clearly the site itself worked just fine. Problem is, every scan resulted in this:

ASafaWeb generic error

Now by design, this is a particularly unhelpful error message which discloses nothing of the underlying problem or possible internal implementation of the code. Not to worry, this is why we have ELMAH – but there was nothing new in the ELMAH log either – in fact there was nothing new anywhere.

You see, in order to keep my costs down (all the way down to $0), I was making use of AppHarbor’s Yocto-scale SQL shared SQL hosting:

AppHarbor's Yocto SQL

That 20 MB fills up pretty fast once you start logging chunky ELMAH events to it! So that was the problem; no space left on the DB meant no writes allowed meant logging couldn’t happen meant scans never completed and rendered to the screen. Bugger indeed.

There’s "Alive”, and then there’s “Alive”

My site was alive, at least in so far as you could load it and as far as any sort of basic uptime monitoring such as Pingdom would be concerned, everything was fine. But just demonstrating that the web service is running is not enough; you’ve got to have confidence that it’s functioning correctly.

This brings us neatly to the value proposition of StillAlive. What these guys have done is built a service that tests actions rather than simply sending out a pulse check to the website. We can take up this service directly from AppHarbor and quickly fill in some profile data which then leads us to a dashboard with the sites we’re presently monitoring:

My StillAlive websites

Courtesy of AppHarbor, this defaults to the ASafaWeb site. Drilling down a little, we get a good view of what this particular site is testing for:

The ASafaWeb site on StillAlive

What we see here is a single script. Scripts are the nuts and bolts of the service – they’re the ones which actually do the work. When we look at what’s happening inside this script, we can see that every four hours the script will run and notify me a maximum of four times after failing once:

The default StillAlive script

Here’s where we start to reach the limits of a free service; any frequency greater than 4-hourly and we need to make a cash contribution.

So out of the box, StillAlive will make sure my site is returning an HTTP 200 “OK”, which is, well, only ok – it’s not that much different than a ping (although at least the web server has to be serving requests). What I really want to do is test that my database can be written to. Of course StillAlive can’t do this on its own, it needs an endpoint on ASafaWeb to test against.

Over to the ASafaWeb codebase, drop in a table to hold some test data, write a little data access method to test that a few thousand bytes can be written then call that from a controller and just return HTTP 200 or 500 depending on the result. Job done. All I need to do now is update that StillAlive script with the updated path.

To make sure everything works just fine, I set the test up to fail then updated the script to point to my test location and hit the “Test Now” button in the earlier image:

Failing script on StillAlive

Perfect. Restore the test on the ASafaWeb website and she’s ready to run. There’s just one more thing to do – decide how I want to be notified:

Notification settings on StillAlive

Email alone is fine for now and a test message looks something like this:

A StillAlive test message

And that’s it – job done! Once it runs for a bit we actually see some sensible looking history:

History of the script on StillAlive

This was also a pretty simplistic demo. StillAlive has a great video which demonstrates how to make a far more intelligent script which actually posts data and looks for particular patterns in the response body.


Like every other add-on I’ve come across in AppHarbor, StillAlive was very simple to implement and the entry-level offering comes free of charge. The script I created above will help keep an eye on that pesky database and make sure the site itself is actually responding (no response means no HTTP 200 will come back). It’s just another little piece in the ASafaWeb armour.

ASafaWeb AppHarbor StillAlive
Tweet Post Update Email RSS

Hi, I'm Troy Hunt, I write this blog, create courses for Pluralsight and am a Microsoft Regional Director and MVP who travels the world speaking at events and training technology professionals