sage/app/sage.py
yumoqing bc5e0f5e82 fix: use add_startup() for cache_sync instead of asyncio.create_task
- init() is called synchronously before the event loop starts
  (configuredServer.py:36), so asyncio.create_task() fails with
  'no running event loop'
- Use ahserver's add_startup() which appends to app.on_startup
  and runs after the loop is ready (configuredServer.py:118)
- Remove unused asyncio import
2026-05-26 17:16:18 +08:00

67 lines
1.9 KiB
Python

import os, sys
import json
import argparse
from appPublic.log import MyLogger, info, debug, warning
from appPublic.folderUtils import ProgramPath
from appPublic.jsonConfig import getConfig
from appPublic.zmqapi import run_proxy, zmq_subscribe
from appPublic.registerfunction import RegisterFunction
from bricks_for_python.init import load_pybricks
from ahserver.webapp import webapp
from ahserver.serverenv import ServerEnv
from ahserver.configuredServer import add_cleanupctx, add_startup
from rbac.init import load_rbac, start_cache_sync
from pricing.init import load_pricing
from appbase.init import load_appbase
from llmage.init import load_llmage
from filemgr.init import load_filemgr
from uapi.init import load_uapi
from dapi.init import load_dapi
from rag.init import load_rag
from msp.init import load_msp
from checklang.init import load_checklang
from discount.init import load_discount
from harnessed_agent.init import load_harnessed_agent
from harnessed_reasoning.init import load_harnessed_reasoning
from hermes_web_cli.init import load_hermes_web_cli
from dashboard_for_sage.init import load_dashboard_for_sage
from global_func import set_globalvariable
from unipay.init import load_unipay
from platformbiz.init import load_platformbiz
from product_management.init import load_product_management
from accounting.init import load_accounting
from smssend import load_smssend
from ext import *
from rf import *
__version__ = '0.0.1'
def init():
rf = RegisterFunction()
set_globalvariable()
load_pybricks()
load_appbase()
load_rbac()
add_startup(start_cache_sync)
load_accounting()
load_unipay()
load_platformbiz()
load_product_management()
load_filemgr()
load_llmage()
load_uapi()
load_dapi()
load_msp()
load_rag()
load_pricing()
load_checklang()
load_harnessed_agent()
load_harnessed_reasoning()
load_discount()
load_hermes_web_cli()
load_smssend()
load_dashboard_for_sage()
if __name__ == '__main__':
webapp(init)