Skip to content

problem with FindBin #18

Closed
gmambro opened this Issue Feb 22, 2011 · 3 comments

2 participants

@gmambro
gmambro commented Feb 22, 2011

If you have a psgi application that uses the FindBin module starman seems to crash when restarting worker processes.

For example if I have a simple app.psgi like

#!/usr/bin/perl
use FindBin;
my $app = sub {
  my $env = shift;
  return [
      '200',
      [ 'Content-Type' => 'text/plain' ],
      [ "Hello World" ],
   ];
}

when I run it with starman -E development --max-requests=1 --workers=1 app.psgi
I just need to do one request make it crash. This what I see on my console:

starman -E development --max-requests=1 --workers=1 app.psgi 
2011/02/22-15:25:20 Starman::Server (type Net::Server::PreFork) starting! pid(3022)
Binding to TCP port 5000 on host *
Setting gid to "100 100 33 100"
Starman: Accepting connections at http://*:5000/
Error while loading app.psgi: Cannot find current script 'starman master -E development --max- requests=1 --workers=1 app.psgi' at /usr/lib/perl5/5.10.0/FindBin.pm line 206
BEGIN failed--compilation aborted at /usr/lib/perl5/5.10.0/FindBin.pm line 206, <_READ> line  2.
Compilation failed in require at app.psgi line 2, <_READ> line 2.
BEGIN failed--compilation aborted at app.psgi line 2, <_READ> line 2.
Error while loading app.psgi: Cannot find current script 'starman master -E development --max-requests=1 --workers=1 app.psgi' at /usr/lib/perl5/5.10.0/FindBin.pm line 206 
...

Maybe FindBin crashes because of the line
$0 = "starman worker " . join(" ", @{$self->{options}{argv} || []});
in Starman::Server::child_init_hook

@miyagawa
Owner

This is a known issue - you should be able to run starman -MFindBin to work around (to remove crashes), but more importantly, FindBin is supposed to cause problems with persistent environment like mod_perl, so you're suggested to use __FILE__ instead.

@gmambro
gmambro commented Feb 23, 2011

Thank you for your quick and kind response. I'm sorry I didn't see this was already discussend in issue#15!
I think it should be nice to have these kind of issues documented in starman manual pages.

Thank you again and congrats for your great work!

@miyagawa
Owner

Yeah, we should document this.

@clkao clkao pushed a commit to clkao/Starman that referenced this issue Jun 30, 2012
@miyagawa Checking in changes prior to tagging of version 0.2008_1.
Changelog diff is:

diff --git a/Changes b/Changes
index 9d3feb4..8088c4c 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,9 @@
 Revision history for Perl extension Starman

+0.2008_1
+        - Requires Plack 0.9971 to support localizing $0 to fix the FindBin issues #7, #15, #18, #19
+        - Calls srand() automatically in the child init hook to avoid a fixed random seed #20
+
 0.2008  Mon Feb 14 17:19:20 PST 2011
         - Documented that -E is automatically set to 'deployment' RT:61517 (timbunce)
         - Check the defined-ness of the input buffer to suppress warnings RT:60007
73fb5ae
@clkao clkao pushed a commit to clkao/Starman that referenced this issue Jun 30, 2012
@miyagawa Checking in changes prior to tagging of version 0.2008_2.
Changelog diff is:

diff --git a/Changes b/Changes
index 8088c4c..e1ee873 100644
--- a/Changes
+++ b/Changes
@@ -1,8 +1,9 @@
 Revision history for Perl extension Starman

-0.2008_1
+0.2008_2
         - Requires Plack 0.9971 to support localizing $0 to fix the FindBin issues #7, #15, #18, #19
         - Calls srand() automatically in the child init hook to avoid a fixed random seed #20
+        - Implemented --keepalive-timeout which defaults to 1 (acme)

 0.2008  Mon Feb 14 17:19:20 PST 2011
         - Documented that -E is automatically set to 'deployment' RT:61517 (timbunce)
982d5b4
@clkao clkao pushed a commit to clkao/Starman that referenced this issue Jun 30, 2012
@miyagawa Checking in changes prior to tagging of version 0.2009.
Changelog diff is:

diff --git a/Changes b/Changes
index e1ee873..add4ebe 100644
--- a/Changes
+++ b/Changes
@@ -1,6 +1,6 @@
 Revision history for Perl extension Starman

-0.2008_2
+0.2009  Fri Mar 25 19:15:23 PDT 2011
         - Requires Plack 0.9971 to support localizing $0 to fix the FindBin issues #7, #15, #18, #19
         - Calls srand() automatically in the child init hook to avoid a fixed random seed #20
         - Implemented --keepalive-timeout which defaults to 1 (acme)
765b0ac
@clkao clkao pushed a commit to clkao/Starman that referenced this issue Jun 30, 2012
@miyagawa Checking in changes prior to tagging of version 0.2010.
Changelog diff is:

diff --git a/Changes b/Changes
index add4ebe..db43c07 100644
--- a/Changes
+++ b/Changes
@@ -1,5 +1,8 @@
 Revision history for Perl extension Starman

+0.2010  Mon Mar 28 16:23:23 PDT 2011
+        - Fixed packaging. No changes.
+
 0.2009  Fri Mar 25 19:15:23 PDT 2011
         - Requires Plack 0.9971 to support localizing $0 to fix the FindBin issues #7, #15, #18, #19
         - Calls srand() automatically in the child init hook to avoid a fixed random seed #20
0cdc8e4
This issue was closed.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.