fixed long shutdown

This commit is contained in:
Maxim Devaev 2021-07-26 07:39:07 +03:00
parent 25c9c63788
commit 365f06a2e8
2 changed files with 4 additions and 0 deletions

View File

@ -240,6 +240,7 @@ class HttpServer:
aiohttp.web.run_app( aiohttp.web.run_app(
app=self._make_app(), app=self._make_app(),
shutdown_timeout=1,
access_log_format=access_log_format, access_log_format=access_log_format,
print=self.__run_app_print, print=self.__run_app_print,
**socket_kwargs, **socket_kwargs,

View File

@ -367,6 +367,8 @@ class KvmdServer(HttpServer): # pylint: disable=too-many-arguments,too-many-ins
for client in list(self.__ws_clients): for client in list(self.__ws_clients):
await self.__remove_ws_client(client) await self.__remove_ws_client(client)
logger.info("On-Shutdown complete")
async def __on_cleanup(self, _: aiohttp.web.Application) -> None: async def __on_cleanup(self, _: aiohttp.web.Application) -> None:
logger = get_logger(0) logger = get_logger(0)
for component in self.__components: for component in self.__components:
@ -376,6 +378,7 @@ class KvmdServer(HttpServer): # pylint: disable=too-many-arguments,too-many-ins
await component.cleanup() # type: ignore await component.cleanup() # type: ignore
except Exception: except Exception:
logger.exception("Cleanup error on %s", component.name) logger.exception("Cleanup error on %s", component.name)
logger.info("On-Cleanup complete")
async def __send_event(self, ws: aiohttp.web.WebSocketResponse, event_type: str, event: Optional[Dict]) -> None: async def __send_event(self, ws: aiohttp.web.WebSocketResponse, event_type: str, event: Optional[Dict]) -> None:
await ws.send_str(json.dumps({ await ws.send_str(json.dumps({