From f623feb8a85a761f441d2a51faf516f323202519 Mon Sep 17 00:00:00 2001 From: Emmanuel Garette Date: Sat, 14 Nov 2020 19:01:28 +0100 Subject: [PATCH] add systemd notifier --- script/risotto-server | 5 ++++- src/risotto/http.py | 5 ++++- 2 files changed, 8 insertions(+), 2 deletions(-) diff --git a/script/risotto-server b/script/risotto-server index 6273d8b..d34582d 100644 --- a/script/risotto-server +++ b/script/risotto-server @@ -1,13 +1,16 @@ #!/usr/bin/env python3 +from sdnotify import SystemdNotifier from asyncio import get_event_loop from risotto import get_app if __name__ == '__main__': + notifier = SystemdNotifier() loop = get_event_loop() loop.run_until_complete(get_app(loop)) + print('HTTP server ready') + notifier.notify("READY=1") try: - print('HTTP server ready') loop.run_forever() except KeyboardInterrupt: pass diff --git a/src/risotto/http.py b/src/risotto/http.py index dae48d8..909b8de 100644 --- a/src/risotto/http.py +++ b/src/risotto/http.py @@ -174,7 +174,10 @@ async def get_app(loop): await dispatcher.register_remote() print() await dispatcher.on_join() - return await loop.create_server(app.make_handler(), '*', get_config()['http_server']['port']) + return await loop.create_server(app.make_handler(), + '*', + get_config()['http_server']['port'], + ) TIRAMISU = None