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
Damjan
2006-08-29
> >>Now I'm trying to do it all in my top-level Python program, doing my
> >>own fork()'s for the Durus servers.
> >
> >You don't need a fork, the Durus database can even be started in a
> >thread. See this example:
> >http://mail.mems-exchange.org/durusmail/durus-users/681/
>
> With this approach, the Durus server also dies when the rest
> of the process dies.  That will be good for some applications,
> but it could also be bad because then the server would need
> to restart every time the client pool is restarted.

Ofcourse, in my case that's allright because the whole process is a long
running twisted application.

Another sollution would be,
def daemonize(chdir=None, umask=None):
    pid = os.fork()
    if pid > 0:
        return pid
    if chdir:
        os.chdir(chdir)
    if umask:
        os.umask(umask)
    os.setsid()
    closefiles()
    return 0

pid = daemonize(chdir='/', umask=0)
if pid == 0:
    # CHILD
    server = StorageServer(...)
    server.serve()
# Do something else in the parent (save the child pid?)
....

Note that I don't use double-fork in daemonize... I don't think it's
needed on Linux.

--
damjan | дамјан
This is my jabber ID -->         damjan@bagra.net.mk
 -- not my mail address, it's a Jabber ID --^ :)
reply