Disable SIGCHLD Handler for now - keeping SIGTERM for DB writes

pull/818/head
dgtlmoon 2 years ago
parent f0f2fe94ce
commit e318253f31

@ -10,7 +10,7 @@ import multiprocessing
import signal
import os
def sigterm_handler(_signo, _stack_frame):
def sigchld_handler(_signo, _stack_frame):
import sys
print('Shutdown: Got SIGCHLD')
# https://stackoverflow.com/questions/40453496/python-multiprocessing-capturing-signals-to-restart-child-processes-or-shut-do
@ -23,7 +23,9 @@ def sigterm_handler(_signo, _stack_frame):
raise SystemExit
if __name__ == '__main__':
signal.signal(signal.SIGCHLD, sigterm_handler)
#signal.signal(signal.SIGCHLD, sigchld_handler)
# The only way I could find to get Flask to shutdown, is to wrap it and then rely on the subsystem issuing SIGTERM/SIGKILL
parse_process = multiprocessing.Process(target=changedetection.main)
parse_process.daemon = True

@ -19,11 +19,10 @@ app = None
def sigterm_handler(_signo, _stack_frame):
global app
global datastore
app.config.exit.set()
datastore.sync_to_json()
# app.config.exit.set()
print('Shutdown: Got SIGTERM, DB saved to disk')
raise SystemExit
datastore.sync_to_json()
# raise SystemExit
def main():
global datastore
@ -91,6 +90,7 @@ def main():
datastore = store.ChangeDetectionStore(datastore_path=app_config['datastore_path'], version_tag=__version__)
app = changedetection_app(app_config, datastore)
signal.signal(signal.SIGTERM, sigterm_handler)
# Go into cleanup mode

Loading…
Cancel
Save