2026-08-31 18:01:34 +08:00
|
|
|
|
"""
|
|
|
|
|
|
unified 入口 — 同时挂载 moldinsight + inventory,供前端同域反代统一访问
|
|
|
|
|
|
"""
|
|
|
|
|
|
import os, sys
|
|
|
|
|
|
from pathlib import Path
|
|
|
|
|
|
|
|
|
|
|
|
src_root = Path(__file__).parent.parent
|
|
|
|
|
|
sys.path.insert(0, str(src_root))
|
|
|
|
|
|
|
|
|
|
|
|
os.chdir(Path(__file__).parent.parent.parent)
|
|
|
|
|
|
|
|
|
|
|
|
from shared.app_factory import create_app
|
2026-09-18 18:21:01 +08:00
|
|
|
|
from moldinsight.storage.init_storage import rustfs_startup_hook
|
2026-08-31 18:01:34 +08:00
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
def _register_routers(app):
|
2026-09-18 18:21:01 +08:00
|
|
|
|
"""注册 unified 业务路由(moldinsight 单点聚合 + inventory)"""
|
2026-08-31 18:01:34 +08:00
|
|
|
|
try:
|
2026-09-18 18:21:01 +08:00
|
|
|
|
from moldinsight.api import register_moldinsight_routers
|
|
|
|
|
|
register_moldinsight_routers(app)
|
2026-08-31 18:01:34 +08:00
|
|
|
|
except Exception as e:
|
|
|
|
|
|
print(f"[WARN] MoldInsight 路由: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
try:
|
|
|
|
|
|
from inventory.api import inventory_router
|
|
|
|
|
|
app.include_router(inventory_router)
|
|
|
|
|
|
except Exception as e:
|
|
|
|
|
|
print(f"[WARN] Inventory 路由: {e}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
app = create_app(
|
|
|
|
|
|
title="Gemold - Unified Backend",
|
|
|
|
|
|
service_name="unified",
|
|
|
|
|
|
serve_frontend_static=False,
|
2026-09-18 18:21:01 +08:00
|
|
|
|
startup_hooks=[rustfs_startup_hook],
|
2026-08-31 18:01:34 +08:00
|
|
|
|
register_routers=_register_routers,
|
|
|
|
|
|
)
|