Skip Menu |

This queue is for tickets about the Catalyst-Runtime CPAN distribution.

Report information
The Basics
Id: 59829
Status: resolved
Priority: 0/
Queue: Catalyst-Runtime

People
Owner: Nobody in particular
Requestors: thomas.erskine@gmail.com (no email address)
Cc:
AdminCc:

Bug Information
Severity: Normal
Broken in: 5.80007
Fixed in: (no value)



Subject: undefs in env and clean exits
If you want to run your catalyst app (script/myapp_server.pl) under a profiler, say NYTProf, they don't like the program to be just killed. It would be nice if the server would catch INT and QUIT and just exit, allowing the app to tear itself down gracefully. If %ENV gets undef values in it, the Catalyst::Engine::HTTP module will spew warnings for each request. Annoying, and when I figure out which other module is doing that, I'll complain there too. Here's a patch against Catalyst-Runtime 5.80007 (being what I've got access to here).
Subject: Catalyst-Engine-HTTP.patch
--- /ms/dist/perl5/PROJ/Catalyst-Runtime/5.80007/lib/perl5/Catalyst/Engine/HTTP.pm 2009-06-20 23:32:59.621976916 -0400 +++ lib/Catalyst/Engine/HTTP.pm 2010-07-29 10:59:39.992521652 -0400 @@ -193,7 +193,10 @@ } my $restart = 0; + my $shutdown = 0; local $SIG{CHLD} = 'IGNORE'; + local $SIG{INT} = sub { $shutdown = 1; }; + local $SIG{QUIT} = sub { $shutdown = 1; }; my $allowed = $options->{allowed} || { '127.0.0.1' => '255.255.255.255' }; my $addr = $host ? inet_aton($host) : INADDR_ANY; @@ -256,7 +259,7 @@ }; LISTEN: - while ( !$restart ) { + while ( !$restart and !$shutdown ) { while ( accept( Remote, $daemon ) ) { DEBUG && warn "New connection\n"; @@ -327,11 +330,10 @@ $daemon->close; - DEBUG && warn "Shutting down\n"; - if ($restart) { $SIG{CHLD} = 'DEFAULT'; wait; + DEBUG && warn "Re-starting\n"; ### if the standalone server was invoked with perl -I .. we will loose ### those include dirs upon re-exec. So add them to PERL5LIB, so they @@ -342,6 +344,7 @@ exec $^X, $0, @{ $options->{argv} }; } + DEBUG && warn "Shutting down\n"; exit; } @@ -357,6 +360,15 @@ my $sockdata = $self->_socket_data( \*Remote ); my %copy_of_env = %ENV; + # Without this hack, it will warn of undefs every time it handles + # a new request and assigns %copy_of_env to th enewly build environment. + foreach my $key (keys %copy_of_env) { + if ( not defined $copy_of_env{$key} ) { + # warn "somehow '$key' has an undef in it\n"; + $copy_of_env{$key} = ''; + } + } + my $sel = IO::Select->new; $sel->add( \*STDIN );
On Thu Jul 29 13:20:54 2010, TERSKINE wrote: Show quoted text
> If you want to run your catalyst app (script/myapp_server.pl) under a > profiler, say NYTProf, they don't like the program to be just killed. > It would be nice if the server would catch INT and QUIT and just exit, > allowing the app to tear itself down gracefully.
I agree, this is entirely reasonable, I'll look into how the Plack web servers handle this before applying the patch however (as we're in the process of porting to Plack) Show quoted text
> If %ENV gets undef values in it, the Catalyst::Engine::HTTP module will > spew warnings for each request. Annoying, and when I figure out which > other module is doing that, I'll complain there too.
You don't happen to know what parts of %ENV are the issue here do you? I'd recommend Value::Canary for finding out who the culprit is... Show quoted text
> Here's a patch against Catalyst-Runtime 5.80007 (being what I've got > access to here).
Thanks for the bug report and patch!
This is believed fixed using the plack server in the latest version of Catalyst.