From a7c3e13fcb47d18ed391f2e7deb5fd50ae800460 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Fri, 15 Oct 2021 15:43:27 -0600 Subject: [PATCH] Improve logging, add watchdog --- main.py | 15 +++++++++++---- 1 file changed, 11 insertions(+), 4 deletions(-) diff --git a/main.py b/main.py index ea6e08a..779a805 100644 --- a/main.py +++ b/main.py @@ -1,9 +1,9 @@ -import os -import logging +import os, logging +DEBUG = os.environ.get('DEBUG') logging.basicConfig( format='[%(asctime)s] %(levelname)s %(module)s/%(funcName)s - %(message)s', - level=logging.DEBUG if os.environ.get('DEBUG') else logging.INFO) -logging.getLogger('aiohttp').setLevel(logging.DEBUG if os.environ.get('DEBUG') else logging.WARNING) + level=logging.DEBUG if DEBUG else logging.INFO) +logging.getLogger('aiohttp').setLevel(logging.DEBUG if DEBUG else logging.WARNING) import os import sys @@ -79,9 +79,16 @@ def init(): signal(sig, disable_relays_on_exit) logging.info('Signals initialized') +async def feed_watchdog(): + while True: + with open('/dev/watchdog', 'w') as wdt: + wdt.write('1') + await asyncio.sleep(1) + if __name__ == '__main__': init() loop = asyncio.get_event_loop() + loop.create_task(feed_watchdog()) loop.run_until_complete(ws_listener()) loop.close()