[Catalyst] Catalyst::Engine needs a stop method

Jon jon+catalyst at youramigo.com
Sat Oct 28 00:30:20 BST 2006


I need to launch a long-running (minutes up to hours) background program
from Catalyst.  I have it working almost well enough - I do the usual
double-fork, closing standard file descriptors, and had to take some
particular care to use POSIX::_exit and put an eval{} around the daemon
code so that if it dies it doesn't return to the Catalyst main loop -
and it runs, exits cleanly and doesn't interfere with other Catalyst
operations.

The problem I'm having is when I stop and try to restart the main
Catalyst server before the background process completes (and I do want
it to continue).  In the standalone server configuration, the main
socket (port 3000) gets inherited and left open, so is held by the
background process and prevents the server restarting.

What I need to be able to do is ask the HTTP engine to stop, close all
its file descriptors and clean up.  There doesn't currently appear to be
any elegant way to do this without knowing which engine you're running
and what port it's using, and even then it is problematic to locate the
file descriptor and close it.

It would be nice if there was a Catalyst::Engine::stop method or similar
to complement Catalyst::Engine::run.  mod_perl provides such a thing 
Apache::SubProcess::cleanup_for_exec (see
http://modperlbook.org/html/ch10_02.html).

Has anyone had similar issues and perhaps found other workarounds?

Thanks.




More information about the Catalyst mailing list