Commit 6d054f73 authored by Vincent Pelletier's avatar Vincent Pelletier

Move logfile and pidfile opening to first process, to let user view errors...

Move logfile and pidfile opening to first process, to let user view errors when those fiels cannot be opened.


git-svn-id: https://svn.erp5.org/repos/public/erp5/trunk@24537 20353a03-c40f-0410-a6d1-a30d3c3de9de
parent da870a56
......@@ -734,17 +734,20 @@ signal.signal(signal.SIGUSR1, USR1Handler)
signal.signal(signal.SIGTERM, TERMHandler)
if options.fork:
os.chdir('/')
os.umask(027)
logfile = LogFile(options.logfile_name)
pidfile = open(options.pidfile_name, 'w')
pid = os.fork()
if pid == 0:
os.umask(027)
os.setsid()
pid = os.fork()
if pid == 0:
pidfile.close()
os.close(0)
os.close(1)
os.close(2)
sys.stdout = sys.stderr = LogFile(options.logfile_name)
os.chdir('/')
sys.stdout = sys.stderr = logfile
try:
main(options.address, options.port)
except:
......@@ -755,12 +758,10 @@ if options.fork:
else:
log('Exited normaly.')
else:
pidfile = open(options.pidfile_name, 'w')
pidfile.write(str(pid))
pidfile.close()
os._exit(0)
else:
# TODO: monitor child startup to make it easier to use.
os._exit(0)
else:
main(options.address, options.port)
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment