first
This commit is contained in:
@@ -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)
|
||||
|
||||
Reference in New Issue
Block a user