join ir.cron threads on SIGTERM for issue604
This commit is contained in:
1 parent
d106175172
commit
5594bb4e11
1 file changed
+8
@@ -191,6 +191,8 @@ class TrytonServer(object):
|
||||
(CONFIG['secure_webdav'] and ' Secure' or '') + \
|
||||
' service, port ' + str(port))
|
||||
|
||||
threads = []
|
||||
|
||||
def handler(signum, frame):
|
||||
if hasattr(signal, 'SIGUSR1'):
|
||||
if signum == signal.SIGUSR1:
|
||||
@@ -205,6 +207,8 @@ class TrytonServer(object):
|
||||
webdavd.stop()
|
||||
if CONFIG['pidfile']:
|
||||
os.unlink(CONFIG['pidfile'])
|
||||
for thread in threads:
|
||||
thread.join()
|
||||
logging.getLogger('web-service').info('stop server')
|
||||
logging.shutdown()
|
||||
sys.exit(0)
|
||||
@@ -242,7 +246,11 @@ class TrytonServer(object):
|
||||
target=cron_obj.pool_jobs,
|
||||
args=(dbname,), kwargs={})
|
||||
thread.start()
|
||||
threads.append(thread)
|
||||
time.sleep(60)
|
||||
for thread in threads[:]:
|
||||
if not thread.isAlive():
|
||||
threads.remove(thread)
|
||||
|
||||
if __name__ == "__main__":
|
||||
SERVER = TrytonServer()
|
||||
|
||||
Reference in new issue
Block a user