> >>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 --^ :)