Improve logging, add watchdog
This commit is contained in:
parent
8874a80ae2
commit
a7c3e13fcb
15
main.py
15
main.py
|
@ -1,9 +1,9 @@
|
||||||
import os
|
import os, logging
|
||||||
import logging
|
DEBUG = os.environ.get('DEBUG')
|
||||||
logging.basicConfig(
|
logging.basicConfig(
|
||||||
format='[%(asctime)s] %(levelname)s %(module)s/%(funcName)s - %(message)s',
|
format='[%(asctime)s] %(levelname)s %(module)s/%(funcName)s - %(message)s',
|
||||||
level=logging.DEBUG if os.environ.get('DEBUG') else logging.INFO)
|
level=logging.DEBUG if DEBUG else logging.INFO)
|
||||||
logging.getLogger('aiohttp').setLevel(logging.DEBUG if os.environ.get('DEBUG') else logging.WARNING)
|
logging.getLogger('aiohttp').setLevel(logging.DEBUG if DEBUG else logging.WARNING)
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import sys
|
import sys
|
||||||
|
@ -79,9 +79,16 @@ def init():
|
||||||
signal(sig, disable_relays_on_exit)
|
signal(sig, disable_relays_on_exit)
|
||||||
logging.info('Signals initialized')
|
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__':
|
if __name__ == '__main__':
|
||||||
init()
|
init()
|
||||||
|
|
||||||
loop = asyncio.get_event_loop()
|
loop = asyncio.get_event_loop()
|
||||||
|
loop.create_task(feed_watchdog())
|
||||||
loop.run_until_complete(ws_listener())
|
loop.run_until_complete(ws_listener())
|
||||||
loop.close()
|
loop.close()
|
||||||
|
|
Loading…
Reference in New Issue
Block a user