Re: Dancer + Starman + HUP = fail
User:
zjt
Date: 6/22/2012 11:51 am
Date: 6/22/2012 11:51 am
Views: 479
Rating: 0
Rating: 0
I forgot to note that the app doesn't die when it experiences this
HUP problem.
It just logs those errors over and over until it fills the disk with logs.
Jesse
It just logs those errors over and over until it fills the disk with logs.
Jesse
On 6/22/12 11:42 AM, Jesse Thompson
wrote:
Take a simple Dancer app:
use Dancer;
get '/hello/:name' => sub {
return "Why, hello there " . param('name');
};
dance;
And then start it up with starman:
/opt/wisc/perl/bin/starman test_app.psgi
2012/06/22-11:18:39 Starman::Server (type Net::Server::PreFork) starting! pid(28723)
Binding to TCP port 5000 on host *
Setting gid to "10 10 10"
Then send the HUP signal:
kill -HUP 28723
This happens the app:
2012/06/22-11:19:40 Server closing!
Sending children hup signal during HUP on prefork server
2012/06/22-11:19:40 HUP'ing server
2012/06/22-11:19:41 Starman::Server (type Net::Server::PreFork) starting! pid(28901)
Binding open file descriptors
Binding to TCP port 5000 on host *
Setting gid to "10 10 10"
Error while loading test_app.psgi: Cannot find current script 'starman master --port 5000 test_app.psgi' at /opt/wisc/perl-5.12.2/perl/lib/5.12.2/FindBin.pm line 205
BEGIN failed--compilation aborted at /opt/wisc/perl-5.12.2/perl/lib/5.12.2/FindBin.pm line 205, <DATA> line 998.
Compilation failed in require at /opt/wisc/perl-5.12.2/perl/lib/site_perl/5.12.2/Dancer/GetOpt.pm line 8, <DATA> line 998.
BEGIN failed--compilation aborted at /opt/wisc/perl-5.12.2/perl/lib/site_perl/5.12.2/Dancer/GetOpt.pm line 8, <DATA> line 998.
Compilation failed in require at /opt/wisc/perl-5.12.2/perl/lib/site_perl/5.12.2/Dancer.pm line 15, <DATA> line 998.
BEGIN failed--compilation aborted at /opt/wisc/perl-5.12.2/perl/lib/site_perl/5.12.2/Dancer.pm line 15, <DATA> line 998.
Compilation failed in require at test_app.psgi line 3, <DATA> line 998.
BEGIN failed--compilation aborted at test_app.psgi line 3, <DATA> line 998
I verified that this does not happen with a normal psgi app such as:
my $app = sub {
my $env = shift;
return [
'200',
[ 'Content-Type' => 'text/plain' ],
[ "Hello World" ], # or IO::Handle-like object
];
};
Notice this in the FindBin docs:
https://metacpan.org/module/FindBin
"KNOWN ISSUES ...FindBinuses aBEGINblock, it'll be executed only once, and only the first caller will get it right ... persistent Perl environments, where you shouldn't use this module ... Which also means that you should avoid usingFindBinin modules that you plan to put on CPAN."
doh! I'm screwed because Dancer::GetOpt is using FindBin.
I tried adding this to test_app.psgi, which didn't fix it:
useFindBin;
FindBin::again();
I tried capturing HUP signals. No luck.
$SIG{HUP} = sub { die "I got the HUP!" };
Anyone got any ideas how to shim in a fix for Dancer/Starman? I'd be fine if Starman just killed itself on HUP, since I have this server wrapped with Solaris SMF, which will restart the server when it dies.
Otherwise, I could avoid using a pre-forking HTTP server (the HUP problem doesn't happen with 'plackup'), but I need the extra workers to handle the traffic.
Jesse