in reply to Re: Plack beer challenge
in thread Plack beer challenge

Ok.

This is exactly the type of answer I was NOT looking for.

While I believe that your links may contain the answer I have already proven to myself beyond any doubt that I am too stupid to properly understand them...

Here is my app:

#!/home/mh/perl514/bin/plackup -s FCGI --listen /tmp/fcgi.sock --daemo +nize --nproc 10 use strict; use warnings; return sub { return [ 200, ["Content-Type" => "text/plain"], ["hi"] ]; }
Started on it's own it actually works - it starts a web-server on port 5000 that delivers the proper result.

But how to make this work in Apache?

I have put this app as "app.psgi" in /usr/lib/cgi-bin and this is my apache-config:

ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/ <Directory "/usr/lib/cgi-bin"> AllowOverride None Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch Order allow,deny Allow from all AddHandler fcgid-script .psgi </Directory>
Now what happens is that when I try point my browser to the plack-app apache I get an internal server error.

The plack-app actually is launched (there is a process visible), but it seems to me that the plack-app and apache cannot communicate as I can see in the error log that fcgid reports a read timeout and the really weird thing is that I have this line in the error log HTTP::Server::PSGI: Accepting connections at http://0:5000

So to me it seems as if Plack is not aware that it runs under apache for some reasons...

The beer is still for grabs...

Replies are listed 'Best First'.
Re^3: Plack beer challenge (#! args)
by tye (Sage) on Sep 29, 2011 at 14:22 UTC
    #!/home/mh­/perl514/b­in/plackup -s FCGI --listen /tmp/fcgi.­sock --da +emoniz­e --nproc 10

    When the kernel honors a #! line, it only handles up to 1 argument. It certainly isn't portable to put so many options on your #! unless some non-standard method (not the Unix kernel) is doing the exec.

    - tye        

      Fair enough.

      I was only trying what I had gathered from a previous posting.

      The main question remains: How is it done properly?

        If what tye is saying has merit, since plackup is all of 9 lines, you could use

        #!/home/mh/perl514/bin/perl -- use strict; use warnings; use Plack::Runner; my $app = sub { return [ 200, [ "Content-Type" => "text/plain" ], ["hi"] ]; }; my $runner = Plack::Runner->new; $runner->parse_options( qw{ -s FCGI --listen / tmp /fcgi.sock --daemonize --nproc 10 }); $runner->run($app); __END__