? my $ctx = $main::context; ? $_mt->wrapper_file("wrapper.mt", "Configure", "Status Directives")->(sub {
The status handler exposes the current states of the HTTP server. This document describes the configuration directives of the handler.
$ctx->{directive}->( name => "status", levels => [ qw(path) ], since => '2.0', desc => <<'EOT', If the argument isON
, the directive registers the status handler to the current path.
EOT
)->(sub {
?>
Access to the handler should be restricted, considering the fact that the status includes the details of in-flight HTTP requests. The example below uses Basic authentication.
= $ctx->{example}->("Exposing status with Basic authentication", <<'EOT'); paths: /server-status: mruby.handler: | require "htpasswd.rb" Htpasswd.new("/path/to/.htpasswd", "status") status: ON EOT ?>
The information returned by the /json
handler can be filtered out using the optional show=module1,module2
parameter.
There are currently three modules defined:
requests
: displays the requests currently in-flight.durations
: displays durations statistics for requests since server start time in seconds (returns all zeros unless duration-stats
is ON
).errors
: displays counters for internally generated errors.main
: displays general daemon-wide stats.
If the argument is ON
, this directive populates duration statistics in seconds, to be consumed by status handlers.
Enabling this feature has a noticeable CPU and memory impact.
Note that the time spent while processing a request in a blocking manner (such as opening a file or a mruby handler that does invoke a network operation) will not be reflected to the process_time
element of the duration stats due to the fact that the timer being used for measuring the time spent is updated only once per loop.