[IMP] extract method to reexec server
bzr revid: chs@openerp.com-20121123140838-pz47cw4jtlxx8e74
This commit is contained in:
parent
246878558c
commit
927c5635b8
|
@ -210,12 +210,7 @@ def quit_on_signals():
|
||||||
|
|
||||||
if getattr(openerp, 'phoenix', False):
|
if getattr(openerp, 'phoenix', False):
|
||||||
# like the phoenix, reborn from ashes...
|
# like the phoenix, reborn from ashes...
|
||||||
strip_args = ['-d', '-u']
|
openerp.service._reexec()
|
||||||
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]
|
|
||||||
|
|
||||||
# FIXME http socket cannot be rebind ?!? socket seems to not be freed, even shutdown() is called
|
|
||||||
os.execv(sys.executable, [sys.executable] + args)
|
|
||||||
return
|
return
|
||||||
|
|
||||||
if config['pidfile']:
|
if config['pidfile']:
|
||||||
|
|
|
@ -22,6 +22,7 @@
|
||||||
import logging
|
import logging
|
||||||
import os
|
import os
|
||||||
import signal
|
import signal
|
||||||
|
import sys
|
||||||
import threading
|
import threading
|
||||||
import time
|
import time
|
||||||
|
|
||||||
|
@ -126,15 +127,25 @@ def start_services_workers():
|
||||||
openerp.multi_process = True
|
openerp.multi_process = True
|
||||||
openerp.service.workers.Multicorn(openerp.service.wsgi_server.application).run()
|
openerp.service.workers.Multicorn(openerp.service.wsgi_server.application).run()
|
||||||
|
|
||||||
|
def _reexec():
|
||||||
|
"""reexecute openerp-server process with (nearly) the same arguments"""
|
||||||
|
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]
|
||||||
|
os.execv(sys.executable, [sys.executable] + args)
|
||||||
|
|
||||||
def restart_server():
|
def restart_server():
|
||||||
if openerp.multi_process:
|
if openerp.multi_process:
|
||||||
raise NotImplementedError("Multicorn is not supported (but gunicorn was)")
|
raise NotImplementedError("Multicorn is not supported (but gunicorn was)")
|
||||||
pid = openerp.wsgi.core.arbiter_pid
|
pid = openerp.wsgi.core.arbiter_pid
|
||||||
os.kill(pid, signal.SIGHUP)
|
os.kill(pid, signal.SIGHUP)
|
||||||
else:
|
else:
|
||||||
openerp.phoenix = True
|
if os.name == 'nt':
|
||||||
signame = 'CTRL_C_EVENT' if os.name == 'nt' else 'SIGINT'
|
# TODO check if parent is a service
|
||||||
sig = getattr(signal, signame)
|
stop_services()
|
||||||
os.kill(os.getpid(), sig)
|
_reexec()
|
||||||
|
else:
|
||||||
|
openerp.phoenix = True
|
||||||
|
os.kill(os.getpid(), signal.SIGINT)
|
||||||
|
|
||||||
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
# vim:expandtab:smartindent:tabstop=4:softtabstop=4:shiftwidth=4:
|
||||||
|
|
Loading…
Reference in New Issue