This commit is contained in:
Your Name
2026-04-16 21:35:47 +08:00
parent ff32aa50bf
commit ebf632e651
86 changed files with 14097 additions and 585 deletions

View File

@@ -1,8 +1,22 @@
import threading
from fastapi import FastAPI
from fastapi.middleware.cors import CORSMiddleware
from app.api.routes import auth, dashboard, settings as settings_routes, imports, detect, domains, exports, logs, runtime
from app.api.routes import auth, dashboard, settings as settings_routes, imports, detect, domains, exports, logs, runtime, juming, sensitive_words
from app.core.config import settings as app_settings
from app.services.cluster_runtime_service import ensure_runtime_schema, register_local_control_heartbeat
_heartbeat_stop_event = threading.Event()
def _control_heartbeat_loop() -> None:
while not _heartbeat_stop_event.is_set():
try:
register_local_control_heartbeat()
except Exception:
pass
_heartbeat_stop_event.wait(30)
app = FastAPI(
title="domainCheck API",
@@ -19,6 +33,19 @@ app.add_middleware(
)
@app.on_event("startup")
def on_startup() -> None:
ensure_runtime_schema()
register_local_control_heartbeat()
_heartbeat_stop_event.clear()
threading.Thread(target=_control_heartbeat_loop, name="control-heartbeat", daemon=True).start()
@app.on_event("shutdown")
def on_shutdown() -> None:
_heartbeat_stop_event.set()
@app.get("/health")
def health() -> dict:
return {
@@ -41,3 +68,5 @@ app.include_router(domains.router, prefix=app_settings.api_prefix)
app.include_router(exports.router, prefix=app_settings.api_prefix)
app.include_router(logs.router, prefix=app_settings.api_prefix)
app.include_router(runtime.router, prefix=app_settings.api_prefix)
app.include_router(juming.router, prefix=app_settings.api_prefix)
app.include_router(sensitive_words.router, prefix=app_settings.api_prefix)