Re: mod_fcgi/perl: Problem with signals
"Marc Prewitt (Chelsea Tech)" <[email protected]>
| Newsgroups | gmane.comp.web.fastcgi.devel |
|---|---|
| Organization | Chelsea Networks |
| Message-ID | <[email protected]> |
This is working for me... I tried your test script and here's what I
get in the log:
A couple of tests:
gi-bin/fcgi/test1.cgi" (uid 1001, gid 1007) started (pid 18090)
did request at test1.cgi line 38.
did request at test1.cgi line 38.
did request at test1.cgi line 38.
did request at test1.cgi line 38.
did 'apachectl graceful' to restart:
[Sat May 7 21:52:26 2005] [notice] SIGUSR1 received. Doing graceful
restart
got signal at test1.cgi line 14.
I'm running apache 1.3.29. Is your cgi running as an external cgi or on
the same machine as your web server? If you're running external, the
warns will go to the error log on the cgi server, not the web server.
As for your question on what to do in signal handlers, this varies on
the perl version you are using. I've had many problems using error
handlers with 5.6.1. 5.8 is much better (apparently the signal handling
was given a major overhaul.) In general things that give you problems
are memory allocation. Probably not a good idea to do your shared
memory deallocation. See if this works better:
sub sig_handler {
$exit_requested = 1;
}
while ($handling_request = ($request->Accept() >= 0)) {
&do_request;
$handling_request = 0;
last if $exit_requested;
}
warn "exiting";
&dealloc_shared_memory;
Albert Leidinger wrote:
> Hi again!
>
> I just tried the example from FastCGI.com/FAQ. How can I see, that the
> handler was called?
> I tried this:
> (some added warns to the example on fastcgi.com)
>
> #!/usr/bin/perl
>
> use FCGI;
> use strict;
>
> my $count = 0;
> my $handling_request = 0;
> my $exit_requested = 0;
>
> my $request = FCGI::Request();
>
> sub sig_handler {
> $exit_requested = 1;
> warn "got signal"; # added to
> get an entry in the apache error-log, but nothing when reloading or
> restarting apache
> exit(0) if !$handling_request; # also didnt get
> this entry in the apache error-log saying the script exited with status 0
> }
>
> $SIG{USR1} = \&sig_handler;
> $SIG{TERM} = \&sig_handler;
> $SIG{PIPE} = 'IGNORE';
>
> while ($handling_request = ($request->Accept() >= 0)) {
> &do_request;
> $handling_request = 0;
> last if $exit_requested;
> }
>
> $request->Finish();
> warn 'stopping'; # added to get
> an entry in apache error-log, just as above - nothing in the apache
> errorlog!
> close( LOG );
>
> exit(0);
>
> sub do_request() {
> print("Content-type: text/html\r\n\r\n", ++$count);
> $request->Finish();
> warn 'did request'; # added to see that
> warn really works. Yepp, those entries are in the apache log for each
> request!
> }
>
>
> I read that programmers should do nearly nothing in a handler because of
> limitations.
> Is warn already too much?
>
> Is my conclusion that the handler isnt executed at all wrong?
>
> thanks
> Albert
>
> ___________________________________
> fastcgi-developers mailing list
> http://fastcgi.com/fastcgi-developers/
___________________________________
fastcgi-developers mailing list
http://fastcgi.com/fastcgi-developers/