background cgi

Robin Becker robin at jessikat.fsnet.co.uk
Thu Nov 1 11:18:32 EST 2001


I'm running apache with freeBSD 4.4 release + Python 2.1.1.

I'm using a python cgi script and wish to get this script to start a background job.
The start script is wrapped to be a user other than nobody.

My invocation of the background process is

cmd = 'nohup detach python script.py XXX \'ARGS\' > ./nohup.out 2>&1'
system(cmd)

certainly control returns to the starting cgi script which resumes
and finishes as expected. Also the bg script.py process seems to start
and works well.

On our test machine which runs 4.4 the job seems to complete normally.
Using ps I can see that the started job has a PPID of 1 ie is now owned
by init.

On the colo machine which runs 4.1.1-stable the jobs seem to get
mysteriously killed. We don't see the final outputs etc and there is no
error info in nohup.out. I am unable to use ps properly as it won't let me
see -x or -a properly (presumably for security reasons).

Is the above command a reasonable way to start up a detached process?

Is the process safe from culling by apache when the apache thread suicides
after performing a certain number of requests?

Is there a way I can get the script.py to tell me if a trappable signal has
been received and which are the likely candidates? I don't want to start
installing handlers for everything in sight.
-- 
Robin Becker



More information about the Python-list mailing list