NAME
HTTP::Server::PSGI::Mortal - An HTTP server that can be killed by an application
SYNOPSIS
my $server = HTTP::Server::PSGI::Mortal->new(%args);
$server->run($app); # run $app until a response emits 'TIME_TO_DIE'
# now pursue program execution
DESCRIPTION
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.
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.
STOPPING THE SERVER
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.
AUTHOR
Laurent Dami, <dami at cpan.org>
LICENSE AND COPYRIGHT
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.