Stories
Slash Boxes
Comments
NOTE: use Perl; is on undef hiatus. You can read content, but you can't post it. More info will be forthcoming forthcomingly.

All the Perl that's Practical to Extract and Report

use Perl Log In

Log In

[ Create a new account ]

Journal of markjugg (792)

Sunday July 22, 2007
09:14 PM

auto-restart HTTP::Server::Simple when modules change

[ #33860 ]
This weekend I worked on making a feature I liked in Catalyst available to other Perl projects. That feature is the ability to have a simple Pure-Perl web server for development, and have it automatically restart itself when application files changes.

By looking at the guts of Catalyst, I found not one, but two modules that could be easily refactored out of Catalyst for shared use. Those are now File::Monitor::Simple, to monitor the application directory for changes, and HTTP::Server::Restarter to handle controlling that process and actually restarting the web server.

I also needed to patch HTTP::Server::Simple to have better signaling handling. But the result is that this now works:

    HTTP::Server::Restarter->monitor;
    HTTP::Server::Simple->new->run;

While there are options you can give to monitor(), the defaults should work fine for Catalyst and possibly others as well.

I'm currently in discussions with catalyst-dev to see about the best way to get this code published and the possibility of Catalyst being refactored to use the extracted modules as well.

The way that Catalyst currently handles this is a bit novel. Instead of sending and receiving a HUP signal, Catalyst sends a (non-standard) RESTART HTTP request from a user-agent to the server, with some some protection that this command comes from the localhost.

The Fine Print: The following comments are owned by whoever posted them. We are not responsible for them in any way.
 Full
 Abbreviated
 Hidden
More | Login | Reply
Loading... please wait.