feat: 消息平台热重载

This commit is contained in:
Junyan Qin
2024-11-16 12:40:57 +08:00
parent 3239c9ec3f
commit bb219889e5
14 changed files with 168 additions and 36 deletions

View File

@@ -6,7 +6,7 @@ import os
import quart
import quart_cors
from ....core import app
from ....core import app, entities as core_entities
from .groups import logs, system, settings, plugins, stats
from . import group
@@ -32,15 +32,26 @@ class HTTPController:
while True:
await asyncio.sleep(1)
async def exception_handler(*args, **kwargs):
try:
await self.quart_app.run_task(
*args, **kwargs
)
except Exception as e:
self.ap.logger.error(f"启动 HTTP 服务失败: {e}")
self.ap.task_mgr.create_task(
self.quart_app.run_task(
exception_handler(
host=self.ap.system_cfg.data["http-api"]["host"],
port=self.ap.system_cfg.data["http-api"]["port"],
shutdown_trigger=shutdown_trigger_placeholder,
),
name="http-api-quart",
scopes=[core_entities.LifecycleControlScope.APPLICATION],
)
# await asyncio.sleep(5)
async def register_routes(self) -> None:
@self.quart_app.route("/healthz")