diff options
author | Maxim Devaev <[email protected]> | 2022-06-19 04:10:42 +0300 |
---|---|---|
committer | Maxim Devaev <[email protected]> | 2022-06-19 04:10:42 +0300 |
commit | 805ff9dd5f43d32caead051c2ff18b72be0672c9 (patch) | |
tree | d7d961344f04961141d8234ff5a6c6392f0b4657 | |
parent | 74e81b6e0345f37695c6cb05dd4fa2e489fd9026 (diff) |
ro_cleanup_delay
-rw-r--r-- | kvmd/apps/__init__.py | 1 | ||||
-rw-r--r-- | kvmd/apps/pst/server.py | 5 | ||||
-rw-r--r-- | kvmd/htserver.py | 6 |
3 files changed, 9 insertions, 3 deletions
diff --git a/kvmd/apps/__init__.py b/kvmd/apps/__init__.py index 89907437..92577a93 100644 --- a/kvmd/apps/__init__.py +++ b/kvmd/apps/__init__.py @@ -497,6 +497,7 @@ def _get_config_scheme() -> Dict: "storage": Option("/var/lib/kvmd/pst", type=valid_abs_dir, unpack_as="storage_path"), "ro_retries_delay": Option(10.0, type=valid_float_f01), + "ro_cleanup_delay": Option(3.0, type=valid_float_f01), "remount_cmd": Option([ "/usr/bin/sudo", "--non-interactive", diff --git a/kvmd/apps/pst/server.py b/kvmd/apps/pst/server.py index 84a62bda..43086249 100644 --- a/kvmd/apps/pst/server.py +++ b/kvmd/apps/pst/server.py @@ -46,6 +46,7 @@ class PstServer(HttpServer): # pylint: disable=too-many-arguments,too-many-inst self, storage_path: str, ro_retries_delay: float, + ro_cleanup_delay: float, remount_cmd: List[str], ) -> None: @@ -53,6 +54,7 @@ class PstServer(HttpServer): # pylint: disable=too-many-arguments,too-many-inst self.__data_path = os.path.join(storage_path, "data") self.__ro_retries_delay = ro_retries_delay + self.__ro_cleanup_delay = ro_cleanup_delay self.__remount_cmd = remount_cmd self.__notifier = aiotools.AioNotifier() @@ -83,7 +85,8 @@ class PstServer(HttpServer): # pylint: disable=too-many-arguments,too-many-inst await aiotools.stop_all_deadly_tasks() logger.info("Disconnecting clients ...") await self.__broadcast_storage_state(False) - await self._close_all_wss() + if (await self._close_all_wss()): + await asyncio.sleep(self.__ro_cleanup_delay) logger.info("On-Shutdown complete") async def _on_cleanup(self) -> None: diff --git a/kvmd/htserver.py b/kvmd/htserver.py index eb364767..94d2c3ee 100644 --- a/kvmd/htserver.py +++ b/kvmd/htserver.py @@ -359,9 +359,11 @@ class HttpServer: ) ], return_exceptions=True) - async def _close_all_wss(self) -> None: - for ws in self._get_wss(): + async def _close_all_wss(self) -> bool: + wss = self._get_wss() + for ws in wss: await self.__close_ws(ws) + return bool(wss) def _get_wss(self) -> List[WsSession]: return list(self.__ws_sessions) |