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()