[OT]starting a long running script
hi, i need to start a long-running script from either mod_perl or mod_cgi, and I'm facing all the well-known issues: the apache child waits, until it waits no longer (maybe because the browser itself chose to close the TCP connection, maybe because of an internal timeout), and then the script gets killed. there is no useful information to echo back to the user, besides teloing him the script started ok. the problem is: while I'm familiar with the problems, but not with the solutions. I've read that one possible solution is to use fork(), but I have no experience with it, and not much understanding of its implications, and after reading perlfunc I'm more confused than before. is there anyone kind enough to tell me where to start Reading TFM or which particular FM contains useful leads? thanks! martin
Re: [OT]starting a long running script
On Tue, 29 Aug 2000, martin langhoff wrote: hi, i need to start a long-running script from either mod_perl or mod_cgi, and I'm facing all the well-known issues: the apache child waits, until it waits no longer (maybe because the browser itself chose to close the TCP connection, maybe because of an internal timeout), and then the script gets killed. there is no useful information to echo back to the user, besides teloing him the script started ok. the problem is: while I'm familiar with the problems, but not with the solutions. I've read that one possible solution is to use fork(), but I have no experience with it, and not much understanding of its implications, and after reading perlfunc I'm more confused than before. is there anyone kind enough to tell me where to start Reading TFM or which particular FM contains useful leads? Very good FM :) http://perl.apache.org/guide/performance.html#Forking_and_Executing_Subprocess thanks! martin _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://jazzvalley.com http://singlesheaven.com http://perlmonth.com perl.org apache.org
Re: [OT]starting a long running script
The easiest way to do this (IMHO) is to use the register_cleanup method in mod_perl. This gets executed at the very end of the request cycle after the TCP connection gets closed. See page 367 of the Eagle book for details... Basically you want to do this: $r = Apache-request; $r-register_cleanup( sub { system("/path/to/your/script.pl"); } ); -T.J. Mather On Tue, 29 Aug 2000, martin langhoff wrote: i need to start a long-running script from either mod_perl or mod_cgi, and I'm facing all the well-known issues: the apache child waits, until it waits no longer (maybe because the browser itself chose to close the TCP connection, maybe because of an internal timeout), and then the script gets killed. there is no useful information to echo back to the user, besides teloing him the script started ok. the problem is: while I'm familiar with the problems, but not with the solutions. I've read that one possible solution is to use fork(), but I have no experience with it, and not much understanding of its implications, and after reading perlfunc I'm more confused than before.
Re: [OT]starting a long running script
On Tue, 29 Aug 2000, T.J. Mather wrote: The easiest way to do this (IMHO) is to use the register_cleanup method in mod_perl. This gets executed at the very end of the request cycle after the TCP connection gets closed. See page 367 of the Eagle book for details... Basically you want to do this: $r = Apache-request; $r-register_cleanup( sub { system("/path/to/your/script.pl"); } ); I'm not sure that this is a good suggestion. While it will let the connection off before starting the process, it'll keep the mod_perl process busy!!! which is something you really don't want to happen. See the URL from my previous post that does the work cleanly and fast. Of course you might want to deploy on of the described techniques in the register_cleanup() mode... -T.J. Mather On Tue, 29 Aug 2000, martin langhoff wrote: i need to start a long-running script from either mod_perl or mod_cgi, and I'm facing all the well-known issues: the apache child waits, until it waits no longer (maybe because the browser itself chose to close the TCP connection, maybe because of an internal timeout), and then the script gets killed. there is no useful information to echo back to the user, besides teloing him the script started ok. the problem is: while I'm familiar with the problems, but not with the solutions. I've read that one possible solution is to use fork(), but I have no experience with it, and not much understanding of its implications, and after reading perlfunc I'm more confused than before. _ Stas Bekman JAm_pH -- Just Another mod_perl Hacker http://stason.org/ mod_perl Guide http://perl.apache.org/guide mailto:[EMAIL PROTECTED] http://apachetoday.com http://jazzvalley.com http://singlesheaven.com http://perlmonth.com perl.org apache.org