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:
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.