Subject: | wish: reliable server restarting |
I like that Catalyst::Engine::HTTP::Restarter can auto-reload the web
server when there are changes. I would like HTTP::Server::Simple to be
able to restartable, too. (The logic that sends it restart commands can
remain external).
Currently, HTTP::Server::Simple claims to respond to the HUP signal, but
this failed badly in my tests. It went into an infinite loop of this:
accept() on closed socket HTTPDaemon at
/usr/local/share/perl/5.8.8/HTTP/Server/Simple.pm line 259, <DATA> line 16.
###
However, there is a note the code that it was known to be wrong or
broken, and code from perlipc should be used instead. I found the
daemon/ipc code from there, but it didn't work for me, either. Instead,
simply "Hangup" was printed on the screen, and the server exited.
This experience leads me to believe that perhaps that the third
approach, taken by Catalyst, is most reliable, since it works there.
It involves simply listening for a special "RESTART" request, and
checking that the request came from an allowed host and netmask,
defaulting to only allowing 127.0.0.1. If those the continues are met,
the server is restarted.
Would you be interested in having that feature if I created the patch?
I might simplify the Catalyst logic to just:
"Always respond to the RESTART command, but only from the
localhost/127.0.0.1".
The option to specify other allowable hosts or netmasks could be added
if needed.
I'm already considering publishing the code that would do the actual
monitoring and send the RESTART requests in its own module:
HTTP::Server::Restarter.
HTTP::Server::Simple would just to respond to RESTARTs when they come in.
Mark