Improve logging, add watchdog

This commit is contained in:
Tanner Collin 2021-10-15 15:43:27 -06:00
parent 8874a80ae2
commit a7c3e13fcb

15
main.py
View File

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