mirror of
https://github.com/mofeng-git/One-KVM.git
synced 2025-12-12 01:00:29 +08:00
refactoring
This commit is contained in:
parent
6b3296c989
commit
047d8ad760
@ -36,7 +36,6 @@ from typing import AsyncGenerator
|
|||||||
from typing import Optional
|
from typing import Optional
|
||||||
from typing import Any
|
from typing import Any
|
||||||
|
|
||||||
from aiohttp.web import Application
|
|
||||||
from aiohttp.web import Request
|
from aiohttp.web import Request
|
||||||
from aiohttp.web import Response
|
from aiohttp.web import Response
|
||||||
from aiohttp.web import WebSocketResponse
|
from aiohttp.web import WebSocketResponse
|
||||||
@ -297,7 +296,7 @@ class KvmdServer(HttpServer): # pylint: disable=too-many-arguments,too-many-ins
|
|||||||
async def _check_request_auth(self, exposed: HttpExposed, request: Request) -> None:
|
async def _check_request_auth(self, exposed: HttpExposed, request: Request) -> None:
|
||||||
await check_request_auth(self.__auth_manager, exposed, request)
|
await check_request_auth(self.__auth_manager, exposed, request)
|
||||||
|
|
||||||
async def _init_app(self, _: Application) -> None:
|
async def _init_app(self) -> None:
|
||||||
self.__run_system_task(self.__stream_controller)
|
self.__run_system_task(self.__stream_controller)
|
||||||
for comp in self.__components:
|
for comp in self.__components:
|
||||||
if comp.systask:
|
if comp.systask:
|
||||||
@ -325,7 +324,7 @@ class KvmdServer(HttpServer): # pylint: disable=too-many-arguments,too-many-ins
|
|||||||
os.kill(os.getpid(), signal.SIGTERM)
|
os.kill(os.getpid(), signal.SIGTERM)
|
||||||
self.__system_tasks.append(asyncio.create_task(wrapper()))
|
self.__system_tasks.append(asyncio.create_task(wrapper()))
|
||||||
|
|
||||||
async def _on_shutdown(self, _: Application) -> None:
|
async def _on_shutdown(self) -> None:
|
||||||
logger = get_logger(0)
|
logger = get_logger(0)
|
||||||
|
|
||||||
logger.info("Waiting short tasks ...")
|
logger.info("Waiting short tasks ...")
|
||||||
@ -344,7 +343,7 @@ class KvmdServer(HttpServer): # pylint: disable=too-many-arguments,too-many-ins
|
|||||||
|
|
||||||
logger.info("On-Shutdown complete")
|
logger.info("On-Shutdown complete")
|
||||||
|
|
||||||
async def _on_cleanup(self, _: Application) -> None:
|
async def _on_cleanup(self) -> None:
|
||||||
logger = get_logger(0)
|
logger = get_logger(0)
|
||||||
for comp in self.__components:
|
for comp in self.__components:
|
||||||
if comp.cleanup:
|
if comp.cleanup:
|
||||||
|
|||||||
@ -325,14 +325,14 @@ class HttpServer:
|
|||||||
async def _check_request_auth(self, exposed: HttpExposed, request: Request) -> None:
|
async def _check_request_auth(self, exposed: HttpExposed, request: Request) -> None:
|
||||||
pass
|
pass
|
||||||
|
|
||||||
async def _init_app(self, app: Application) -> None:
|
async def _init_app(self) -> None:
|
||||||
raise NotImplementedError
|
raise NotImplementedError
|
||||||
|
|
||||||
async def _on_shutdown(self, app: Application) -> None:
|
async def _on_shutdown(self) -> None:
|
||||||
_ = app
|
pass
|
||||||
|
|
||||||
async def _on_cleanup(self, app: Application) -> None:
|
async def _on_cleanup(self) -> None:
|
||||||
_ = app
|
pass
|
||||||
|
|
||||||
# =====
|
# =====
|
||||||
|
|
||||||
@ -342,9 +342,16 @@ class HttpServer:
|
|||||||
remove_slash=True,
|
remove_slash=True,
|
||||||
merge_slashes=True,
|
merge_slashes=True,
|
||||||
)])
|
)])
|
||||||
self.__app.on_shutdown.append(self._on_shutdown)
|
|
||||||
self.__app.on_cleanup.append(self._on_cleanup)
|
async def on_shutdown(_: Application) -> None:
|
||||||
await self._init_app(self.__app)
|
await self._on_shutdown()
|
||||||
|
self.__app.on_shutdown.append(on_shutdown)
|
||||||
|
|
||||||
|
async def on_cleanup(_: Application) -> None:
|
||||||
|
await self._on_cleanup()
|
||||||
|
self.__app.on_cleanup.append(on_cleanup)
|
||||||
|
|
||||||
|
await self._init_app()
|
||||||
return self.__app
|
return self.__app
|
||||||
|
|
||||||
def __run_app_print(self, text: str) -> None:
|
def __run_app_print(self, text: str) -> None:
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user