sig-handler
dgtlmoon 2 years ago
parent 27117b324d
commit f2f8469891

@ -7,9 +7,17 @@
from changedetectionio import changedetection
import multiprocessing
import signal
if __name__ == '__main__':
def sigterm_handler(_signo, _stack_frame):
print('Shutdown: Got SIGCHLD')
print('Process: %d interupted %s. Done editing' % (_signo, _stack_frame))
raise SystemExit
if __name__ == '__main__':
signal.signal(signal.SIGCHLD, sigterm_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

@ -88,6 +88,7 @@ def main():
"Or use the -C parameter to create the directory.".format(app_config['datastore_path']), file=sys.stderr)
sys.exit(2)
datastore = store.ChangeDetectionStore(datastore_path=app_config['datastore_path'], version_tag=__version__)
app = changedetection_app(app_config, datastore)
signal.signal(signal.SIGTERM, sigterm_handler)

Loading…
Cancel
Save