Skip to content

Instantly share code, notes, and snippets.

@tatsuru
Created October 6, 2014 12:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save tatsuru/2ff4b6c25e4133c9af12 to your computer and use it in GitHub Desktop.
Save tatsuru/2ff4b6c25e4133c9af12 to your computer and use it in GitHub Desktop.
plack sample
use Plack::Builder;
my $app = sub {
return [ 200, [ 'Content-Type' => 'text/plain' ], [ 'Hello World' ] ];
};
builder {
enable "ServerStatus::Lite", path => '/server-status', allow => ['127.0.0.1'], scoreboard => '/dev/shm/server-status', counter_file => '/tmp/counter_file';
$app;
};
requires 'Plack';
requires 'Plack::Middleware::ServerStatus::Lite';
@tatsuru
Copy link
Author

tatsuru commented Oct 6, 2014

carton exec -- plackup --port 8000 app.psgi

@tatsuru
Copy link
Author

tatsuru commented Oct 6, 2014

$ curl 'http://localhost:8000/server-status?json'; echo
{"Uptime":"1412598669","BusyWorkers":"1","TotalAccesses":"4","TotalKbytes":"1","IdleWorkers":"0","stats":[{"method":"GET","pid":10260,"protocol":"HTTP/1.1","remote_addr":"127.0.0.1","uri":"/server-status?json","ss":0,"host":"localhost:8000","status":"A"}]}

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment