durusmail: quixote-users: Organizing a Quixote/Durus multiprocess application
Organizing a Quixote/Durus multiprocess application
2006-08-28
Re: Organizing a Quixote/Durus multiprocess application
2006-08-28
2006-08-28
2006-08-29
Organizing a Quixote/Durus multiprocess application
2006-08-28
2006-08-29
2006-08-29
2006-08-29
2006-08-29
2006-08-30
2006-08-31
Mike Orr (2 parts)
2006-09-01
Organizing a Quixote/Durus multiprocess application
2006-08-29
Organizing a Quixote/Durus multiprocess application
Mike Orr
2006-08-31
Here's what I've got so far.  Does it look reasonable?

I first divert sys.stdout and sys.stderr to a logfile unless envvar
"NO_LOG" is set.  This will be used by all subprocesses.  I don't want
some output sent to the console or swallowed up depending on where the
exception hits.  Then I fork and (in the child) start the Durus server
for the sessions db, and (in the parent) start the SCGI server.  I
catch KeyboardInterrupt in both cases to avoid a traceback in the log
file.  I'm using None for both the Quixote error log and the Durus
error log to prevent those packages from redirecting it further.

It took a while to get the file ownerships and umask correct, but I
finally got it working as user 'apache' from the command line.
But if I start it as a daemon and then stop it, it doesn't kill the
Durus server.  That must be because it's using SIGTERM instead of
SIGINT.  I added some code to kill it manually if it's still running,
but that doesn't help.

I may switch to a TCP socket if it gets too frustrating managing the
Unix socket, but I don't think that will help the current problem

Another issue is getting rid of Durus's "sys.stdout already customized.
sys.stderr already customized." messages in the log file.  I set
logginglevel to 101 but that doesn't help because the messages are
sent before that gets set.  I may replace durus.logging.direct_output
to get rid of them.

Another issue is in scgi_server.  I sometimes get a KeyError on
"self.reap_children(self.children[pid])".  I assume that means the
SCGI subprocess has already died, because one of them gave a
permission exception earlier.  I think scgi_server should silently
ignore this error?

I am happy that Quixote and Durus and scgi_server are simple enough
you can follow the code and usually fix problems yourself.  That has
helped me quite a bit in my last few applications.  I'm just getting
into new territory with Unix sockets and fork and how child processes
terminate.

--
Mike Orr 
reply