diff --git a/v6d0auth/app.py b/v6d0auth/app.py index 55c8b99..7c3dba5 100644 --- a/v6d0auth/app.py +++ b/v6d0auth/app.py @@ -7,12 +7,11 @@ from nacl.signing import VerifyKey from nacl.utils import random from v6d0auth import certs - -__all__ = ('V6D0AuthAppFactory',) - from v6d0auth.appfactory import AppFactory from v6d0auth.cdb import CDB, Role, AbstractRequest +__all__ = ('V6D0AuthAppFactory',) + class V6D0AuthAppFactory(AppFactory): def __init__(self, cdb: CDB): diff --git a/v6d0auth/run_app.py b/v6d0auth/run_app.py index 09265a8..0f6f4c4 100644 --- a/v6d0auth/run_app.py +++ b/v6d0auth/run_app.py @@ -1,4 +1,5 @@ import asyncio +import signal from aiohttp import web @@ -18,6 +19,13 @@ async def start_app(app: web.Application): "(Press CTRL+C to quit)".format(", ".join(names)) ) + loop = asyncio.get_running_loop() + + def sigtermed(*_args): + loop.create_task(app.shutdown()) + + signal.signal(signal.SIGTERM, sigtermed) + async def run_app(app: web.Application): await start_app(app)