[FIX] restart of server on windows

bzr revid: chs@openerp.com-20121126122220-38s3hla3hyl1b15p
This commit is contained in:
Christophe Simonis 2012-11-26 13:22:20 +01:00
parent 452d1af646
commit bec3abd64c
1 changed files with 7 additions and 3 deletions

View File

@ -129,6 +129,7 @@ def start_services_workers():
def _reexec():
"""reexecute openerp-server process with (nearly) the same arguments"""
# TODO check if parent is a NT service
strip_args = ['-d', '-u']
a = sys.argv[:]
args = [x for i, x in enumerate(a) if x not in strip_args and a[max(i - 1, 0)] not in strip_args]
@ -141,9 +142,12 @@ def restart_server():
os.kill(pid, signal.SIGHUP)
else:
if os.name == 'nt':
# TODO check if parent is a service
stop_services()
_reexec()
def reborn():
stop_services()
_reexec()
# run in a thread to let the current thread return response to the caller.
threading.Thread(target=reborn).start()
else:
openerp.phoenix = True
os.kill(os.getpid(), signal.SIGINT)