/ domm

I hack Perl for fun and profit

Follow me on twitter!
Atom Icom ... on Atom!
18.06.2016: 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.

Comments (via disqus)

12.06.2016: Recent activity
24.04.2016: Announcing Alpine Perl Workshop 2016
30.01.2016: App::TimeTracker::Command::Category
24.11.2015: Vienna.pm TechMeet
04.09.2015: Things I learned at YAPC::Europe 2015 in Granada
01.08.2015: Announcing Measure::Everything
26.07.2015: Announcing InfluxDB::LineProtocol
02.07.2015: How to notify 1/14th of your users every fortnight
14.06.2015: Make a playlist quickly