Re: [Speedycgi-users] Catching end of process / shutdown handler
Brought to you by:
samh
|
From: Sam H. <sa...@da...> - 2002-07-08 14:31:42
|
You should be able to do this with a shutdown handler. The perl
interperter backend is the same whether you use "mod_speedycgi" or
"speedy" as the frontend.
Here's a test script. Put this in your mod_speedycgi directory and
run it by doing an http request. Five seconds later, a file named
"/tmp/data" should show up when the backend times out and shuts down.
#!/usr/bin/speedy -- -t5
use CGI::SpeedyCGI;
sub save_data {
open(F, ">>/tmp/data"); print F "data\n"; close(F);
}
BEGIN {
CGI::SpeedyCGI->add_shutdown_handler(\&save_data);
}
print "Content-type: text/plain\n\nhello world\n";
> Folks
>
> Is there are way to catch the end of life of a SpeedyCGI front-end
> process? What I am looking for is sort of a shutdown handler like the
> SpeedyCGI CGI module provides, however I am utilizing the SpeedyCGI
> Apache module which does not provide this functionality. Obviously, END
> blocks are ignored in a persistent environment and trying to do it via
> signal handling seems a little hairy if not unreliable.
>
> As a specific example: a CGI app uses session tracking, keeping the
> session data as a per process hash persistently in memory. If the
> process dies due to inactivity, max runs or whatever, it should perform
> one last clean-up job, i.e. flushing the remains of the session data to
> disk. Of course, one could store or tie the session data on each
> invocation to disk, loosing some efficiency, but I want to reap the
> benefits of persistency!
>
>
> Thanks!
>
> Philippe Wiede
> megapublic inc.
>
> Attention, please ensure for your reply not to use one
> of the following mail server addresses as they are not
> allowed to access the megapublic network:
>
> altavista. - bigfoot.com - bol.com.br - caramail.com - desertmail.com
> email.com - emediatemail.com - eudoramail.com - excite.
> flashmail.com - hotbot.com - hotmail. - iwon. - juno.com
> katamail.com - lycos.com - msn.com - mail.com - mail4you.de
> mailcity.com - n2mail.com - netscape. - newmail.com
> sprintmail.com - uol. - usa.net - visitmail.com - webtv.net - yahoo.
>
>
> -------------------------------------------------------
> This sf.net email is sponsored by:ThinkGeek
> Oh, it's good to be a geek.
> http://thinkgeek.com/sf
> _______________________________________________
> Speedycgi-users mailing list
> Spe...@li...
> https://lists.sourceforge.net/lists/listinfo/speedycgi-users
|