maybe sigterm maybe handling

This commit is contained in:
AF 2022-11-01 07:26:00 +00:00
parent 57b4102016
commit 4c5dbaefec
2 changed files with 10 additions and 3 deletions

View File

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

View File

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