HTTP::Server::PSGI::Mortal - An HTTP server that can be killed by an application
my $server = HTTP::Server::PSGI::Mortal->new(%args); $server->run($app); # run $app until a response emits 'TIME_TO_DIE' # now pursue program execution
This server behaves exactly like HTTP::Server::PSGI, except that whenever a response contains a true value in header TIME_TO_DIE, the server's accept loop will stop.
TIME_TO_DIE
It may be useful if you want a program to become a HTTP server at some point, until a specific request ends the service and the program resumes normal execution. This is what happens for example in Tree::Navigator::App::PerlDebug, where a call to debug() stops normal program execution, starts a web server to browse through datastructures and packages, until the web server is stopped through a _KILL http request.
debug()
_KILL
For stopping the server, the application hosted by the call to $server->run($app) should issue a response containing a special header named TIME_TO_DIE, with a true value.
$server->run($app)
Laurent Dami, <dami at cpan.org>
<dami at cpan.org>
Copyright 2012 Laurent Dami.
This program is free software; you can redistribute it and/or modify it under the terms of either: the GNU General Public License as published by the Free Software Foundation; or the Artistic License.
See http://dev.perl.org/licenses/ for more information.
To install HTTP::Server::PSGI::Mortal, copy and paste the appropriate command in to your terminal.
cpanm
cpanm HTTP::Server::PSGI::Mortal
CPAN shell
perl -MCPAN -e shell install HTTP::Server::PSGI::Mortal
For more information on module installation, please visit the detailed CPAN module installation guide.