[Catalyst] Self restarting test server for Win32!

Matt S Trout dbix-class at trout.me.uk
Wed Nov 2 15:10:51 CET 2005


On Wed, Nov 02, 2005 at 01:41:36PM +0000, Will Hawes wrote:
> That's very similar to what I had in mind, although I hadn't thought about triggering the restart over HTTP.
> 
> I have set up a test script that creates two sockets in the main process - one for HTTP traffic and another listening on a different port for restart commands. I then run inside a while(1) loop monitoring the HTTP socket in the same way the current test server does, but I also check the other socket at each iteration. If it receives whatever command is designated as "restart the server" (currently a simple "1"), it closes the server sockets properly and then exits. The restart message is sent from within a forked (or not, as the case may be on Win32) process analogous to  $restarter in the current test server.
> 
> This is all working well and should be possible to incorporate in the test server.

I rather like the HTTP approach, given the current server already restarts
cleanly on SIGHUP - maybe instead of a simple $GOT_HUP variable the Engine
could have an ->restart_scheduled accessor, then the code becomes

$SIG{HUP} = sub { $self->restart_scheduled(1); };

and the restart code changes to

if ($self->restart_scheduled) { # instead of if ($GOT_HUP)

then you can simply have an action that sets restart_scheduled for the
win32 restart - or maybe make the Engine shared into a restarter thread.

-- 
     Matt S Trout       Specialists in Perl consulting, web development, and
  Technical Director    UNIX/Linux systems architecture and automation. Mail
Shadowcat Systems Ltd.  mst (at) shadowcatsystems.co.uk for more information

 + Help us build a better perl ORM: http://dbix-class.shadowcatsystems.co.uk/ +



More information about the Catalyst mailing list