Announcing Plack::App::ServiceStatus

Here's a small piece of code I hacked together monday afternoon to better monitor our apps: Plack::App::ServiceStatus

It's a Plack app (not a middleware!) similar to the various Plack*Status modules (but most of them are middlewares). Plack::App::ServiceStatus returns some JSON indicating if your server is up and running (boring) and if your server can actually reach other services (not so boring, I hope). While you can (and should) monitor each and every service on it's own, sometimes it's also interesting if various services can actually talk with each other (especially if they are not running on the same server or data center).

Usage, straight from the POD:

use Plack::Builder;
use Plack::App::ServiceStatus;

my $schema = YourApp::Schema->connect( ... ); # DBIx::Class
my $es     = Search::Elasticsearch->new;

my $status_app = Plack::App::ServiceStatus->new(
    app           => 'your app',
    DBIC          => $schema,
    Elasticsearch => $es,

builder {
  mount "/_status" => $status_app;
  mount "/" => $your_app;

Now you can check the status:

curl http://localhost:3000/_status  | json_pp
   "app" : "Your app",
   "started_at" : 1465823638,
   "uptime" : 42,
   "checks" : [
         "status" : "ok",
         "name" : "Your app"
         "name" : "Elasticsearch",
         "status" : "ok"
         "name" : "DBIC",
         "status" : "ok"

I really like the concept of writing small, self-contained Plack applications, and then stitching them together via Plack::Builder. And if you use the wonderful OX (or some other Bread::Board based toolkit), initiating all of the services is a breeze!

Thanks to Farhad Shahbazi for providing some feedback and discussion while implementing, and to Validad for supporting Open Source Software.