Merge pull request #27 from horjulf/develop

Gracefully shutdown
pull/28/head^2
Filipe Santos 7 years ago committed by GitHub
commit d9cc07ab48
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -2,6 +2,7 @@
import os.path
import sys
import time
import signal
import click
import schedule
@ -701,13 +702,19 @@ def init_notifications():
return
# Handles exit signals, cancels jobs and exits cleanly
def exit_handler(signum, frame):
log.info(f"Received {signal.Signals(signum).name}, canceling jobs and exiting.")
schedule.clear()
exit()
############################################################
# MAIN
############################################################
if __name__ == "__main__":
print("""
,--. ,--. ,--.
,-' '-.,--.--. ,--,--.| |,-.,-' '-. ,--,--.,--.--.,--.--.
'-. .-'| .--'' ,-. || /'-. .-'' ,-. || .--'| .--'
@ -723,4 +730,10 @@ if __name__ == "__main__":
# GNU General Public License v3.0 #
#########################################################################
""")
# Register the signal handlers
signal.signal(signal.SIGTERM, exit_handler)
signal.signal(signal.SIGINT, exit_handler)
# Start application
app()

Loading…
Cancel
Save