mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 09:10:30 +08:00
ro_cleanup_delay
This commit is contained in:
parent
74e81b6e03
commit
805ff9dd5f
@ -497,6 +497,7 @@ def _get_config_scheme() -> Dict:
|
|||||||
|
|
||||||
"storage": Option("/var/lib/kvmd/pst", type=valid_abs_dir, unpack_as="storage_path"),
|
"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_retries_delay": Option(10.0, type=valid_float_f01),
|
||||||
|
"ro_cleanup_delay": Option(3.0, type=valid_float_f01),
|
||||||
|
|
||||||
"remount_cmd": Option([
|
"remount_cmd": Option([
|
||||||
"/usr/bin/sudo", "--non-interactive",
|
"/usr/bin/sudo", "--non-interactive",
|
||||||
|
|||||||
@ -46,6 +46,7 @@ class PstServer(HttpServer): # pylint: disable=too-many-arguments,too-many-inst
|
|||||||
self,
|
self,
|
||||||
storage_path: str,
|
storage_path: str,
|
||||||
ro_retries_delay: float,
|
ro_retries_delay: float,
|
||||||
|
ro_cleanup_delay: float,
|
||||||
remount_cmd: List[str],
|
remount_cmd: List[str],
|
||||||
) -> None:
|
) -> 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.__data_path = os.path.join(storage_path, "data")
|
||||||
self.__ro_retries_delay = ro_retries_delay
|
self.__ro_retries_delay = ro_retries_delay
|
||||||
|
self.__ro_cleanup_delay = ro_cleanup_delay
|
||||||
self.__remount_cmd = remount_cmd
|
self.__remount_cmd = remount_cmd
|
||||||
|
|
||||||
self.__notifier = aiotools.AioNotifier()
|
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()
|
await aiotools.stop_all_deadly_tasks()
|
||||||
logger.info("Disconnecting clients ...")
|
logger.info("Disconnecting clients ...")
|
||||||
await self.__broadcast_storage_state(False)
|
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")
|
logger.info("On-Shutdown complete")
|
||||||
|
|
||||||
async def _on_cleanup(self) -> None:
|
async def _on_cleanup(self) -> None:
|
||||||
|
|||||||
@ -359,9 +359,11 @@ class HttpServer:
|
|||||||
)
|
)
|
||||||
], return_exceptions=True)
|
], return_exceptions=True)
|
||||||
|
|
||||||
async def _close_all_wss(self) -> None:
|
async def _close_all_wss(self) -> bool:
|
||||||
for ws in self._get_wss():
|
wss = self._get_wss()
|
||||||
|
for ws in wss:
|
||||||
await self.__close_ws(ws)
|
await self.__close_ws(ws)
|
||||||
|
return bool(wss)
|
||||||
|
|
||||||
def _get_wss(self) -> List[WsSession]:
|
def _get_wss(self) -> List[WsSession]:
|
||||||
return list(self.__ws_sessions)
|
return list(self.__ws_sessions)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user