[FIX] core: correcly handle pidfile deletion.

As atexit function are inherited by subprocess, the pidfile was always
deleted when the first worker (http or cron) died. Now, only the
process that created the pidfile will delete it.
This commit is contained in:
Christophe Simonis 2015-11-26 10:40:59 +01:00
parent b459c4dc03
commit 78ea8eb058
1 changed files with 5 additions and 5 deletions

View File

@ -80,9 +80,9 @@ def report_configuration():
('database user', config['db_user'])]:
_logger.info("%s: %s", name, value)
def rm_pid_file():
def rm_pid_file(main_pid):
config = openerp.tools.config
if not openerp.evented and config['pidfile']:
if config['pidfile'] and main_pid == os.getpid():
try:
os.unlink(config['pidfile'])
except OSError:
@ -95,10 +95,10 @@ def setup_pid_file():
"""
config = openerp.tools.config
if not openerp.evented and config['pidfile']:
pid = os.getpid()
with open(config['pidfile'], 'w') as fd:
pidtext = "%d" % (os.getpid())
fd.write(pidtext)
atexit.register(rm_pid_file)
fd.write(str(pid))
atexit.register(rm_pid_file, pid)
def export_translation():