diff --git a/main.py b/main.py index 9707add..1904483 100644 --- a/main.py +++ b/main.py @@ -14,7 +14,7 @@ from email.mime.text import MIMEText import cherrypy import logging -logging.basicConfig(filename='app.log', filemode='w', +logging.basicConfig(stream=sys.stdout, format='%(name)s - %(levelname)s - %(message)s') @@ -49,7 +49,7 @@ class SMTPWebhookApp: try: client = smtplib.SMTP(host=SMTP_SERVER_HOST, port=SMTP_SERVER_PORT) - except Exception as e: + except (smtplib.SMTPConnectionError, TimeoutError) as e: time.sleep(0.2) logging.error("To: {}, error: {}".format(TO_MAIL, e)) return {"status": 400, "message": "SMTP client error: {}.".format( @@ -109,6 +109,10 @@ if __name__ == "__main__": cherrypy.tree.mount(ROOT, config={}) + if hasattr(ENGINE, "signal_handler"): + ENGINE.signal_handler.subscribe() + if hasattr(ENGINE, "console_control_handler"): + ENGINE.console_control_handler.subscribe() try: ENGINE.start() except Exception: # pylint: disable=broad-except