[cgiapp] CGI::App FastCGI and Forking Behavior
Justin J
justin at dadamailproject.com
Thu Jan 8 19:33:23 EST 2015
Looks good - thanks for the reply, Thomas.
My app.cgi looks much like this now,
#!/usr/bin/perl -w
use CGI::Fast;
use App;
while (my $q = new CGI::Fast) {
my $app = new App(QUERY => $q);
$app->run();
}
Which I like, since if I want to run the CGI::App under plain CGI, all I gotta do is swap out this small app.cgi for one specifically for CGI. I can live with that.
And all is right with the world, except POST vars aren't being read.
Changing form method's in the HTML from, "post" to, "get" makes things work just fine though. Looks like I'm missing another piece of the puzzle, unfortunately.
Doing some searching, it seems to be a problem with quite a few users of FastCGI the protocol (Seems pretty language agnostic), but I haven't figured out any workarounds. I've made sure to update all the related modules (CGI::App, CGI, CGI::Fast, FCGI), but that doesn't seem to have much of an impact.
I've added an, "exit" at the end of the while loop of my, "app.cgi" script,
while (my $q = new CGI::Fast) {
my $app = new App(QUERY => $q);
$app->run();
exit;
}
just to stop the persistence, and see if it isn't a problem with something being cached, but the behavior of not see the post vars persists. My guess is that they're just need being read via STDIN (seems FastCGI does things a little differently), but I don't know how to nudge Fast::CGI to do what I want. CGI::Fast doesn't even mention anything about POST params.
There's something obvious I'm now missing?
--
Justin
> On Jan 8, 2015, at 11:11 AM, Thomas Krichel <krichel at openlib.org> wrote:
>
> Justin J writes
>
>> I don't know what I should worry about, or what has been figure out.
>
> Well, for what it's worth, here is what I have done when migrationg a project
> to CGI::App with, hopefully, fastCGI under suxexec. I run apache mod_fcgid.
> It's a module I can much recommend, it is rock solid.
>
> To illustrate, my application is ernad.
>
> In /etc/apache2/sites-available/ernad.repec.org
>
> RewriteEngine on
> RewriteRule ^/$ /cgi-bin/nep_ernad.fcgi$1 [L]
>
> ScriptAlias /cgi-bin /var/www/ernad/cgi-bin
> <directory /var/www/ernad/cgi-bin>
> AddHandler fcgid-script .fcgi
> AllowOverride None
> Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
> Order allow,deny
> Allow from all
> </directory>
>
> <location />
> AddHandler fcgid-script .fcgi
> Options ExecCGI FollowSymLinks
> </location>
>
> Here is /var/www/ernad/cgi-bin/nep_ernad.fcgi
>
> #!/usr/bin/perl -w
>
> use lib qw(/home/ernad/ernad/perl/);
> use CGI::Fast qw/-utf8/;
>
> use Ernad::Erimp;
> use Ernad::Index;
>
> my $impna='nep';
>
> our $e=Ernad::Erimp->new({'impna'=>$impna}) or die;
>
> while (my $q = new CGI::Fast) {
> my $app = new Ernad::Index(QUERY => $q);
> $app->run();
> }
>
> This approach seems to work fine. Apache fires up a new fcgi daemon
> when none is running and a request comes along. I don't need
> a startup script for the fcgi daemon.
>
> My application is supposed to create an application object, an Erimp,
> when it starts. This loads the stylesheets, so they are compiled
> when a request arrives. The other day I changed the stylesheet without
> the killing---thus restarting---the daemon, and it showed the results
> of the changed sheet, which it should not have done, so I need to
> look into this more, but as far I understand, this is the sort
> of setup you need to run CGI::App as FastCGI without much trouble.
>
> --
>
> Cheers,
>
> Thomas Krichel http://openlib.org/home/krichel
> skype:thomaskrichel
>
> ##### CGI::Application community mailing list ################
> ## ##
> ## To unsubscribe, or change your message delivery options, ##
> ## visit: http://lists.openlib.org/mailman/listinfo/cgiapp ##
> ## ##
> ## Web archive: http://lists.openlib.org/pipermail/cgiapp/ ##
> ## Wiki: http://cgiapp.erlbaum.net/ ##
> ## ##
> ################################################################
>
More information about the cgiapp
mailing list