Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

在正式部署的时候,modify_db, init_xxx就不需要执行了,请教需要怎么调整 #5

Open
kanbang opened this issue Jul 17, 2024 · 2 comments

Comments

@kanbang
Copy link

kanbang commented Jul 17, 2024

@asynccontextmanager
async def lifespan(_app: FastAPI):
    start_time = time.time()
    try:
        await modify_db()
        await init_menus()
        await refresh_api_list()
        await init_users()
        await Log.create(log_type=LogType.SystemLog, log_detail_type=LogDetailType.SystemStart)

        yield
    finally:

        end_time = time.time()
        runtime = end_time - start_time
        logger.info(f"App {_app.title} runtime: {runtime} seconds")  # noqa
        await Log.create(log_type=LogType.SystemLog, log_detail_type=LogDetailType.SystemStop)

直接去掉这些代码,会报错误

@sleep1223
Copy link
Owner

保留即可, 函数里有判断是否需要执行初始化
部分数据库需要modify_db里的commend.init来阻塞等待连接数据库成功

@kanbang
Copy link
Author

kanbang commented Aug 13, 2024

谢谢,大佬,咱们的前端有更新soybean-admin新版的计划吗

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants