modify 更换orm框架
This commit is contained in:
@@ -5,9 +5,9 @@ FastAPI + Tortoise-ORM + {{ cookiecutter.project_name }} 示例
|
||||
主入口文件,适配 {{ cookiecutter.project_name }} 打包系统
|
||||
"""
|
||||
import sys
|
||||
import os
|
||||
from utils.launch import launch
|
||||
from multiprocessing import freeze_support
|
||||
import server
|
||||
|
||||
|
||||
def app_run(app_config: dict, default_config: dict):
|
||||
@@ -19,7 +19,7 @@ def app_run(app_config: dict, default_config: dict):
|
||||
default_config: 默认配置
|
||||
"""
|
||||
import uvicorn
|
||||
from app.logger import setup_logging, get_logger # type: ignore
|
||||
from app.core.logger import setup_logging, get_logger # type: ignore
|
||||
|
||||
setup_logging(app_config["logging"])
|
||||
logger = get_logger("app")
|
||||
@@ -47,10 +47,8 @@ def app_run(app_config: dict, default_config: dict):
|
||||
logger.info(f"👥 Workers: {workers}")
|
||||
logger.info("=" * 50)
|
||||
|
||||
# 关键修改:根据 reload 模式选择不同的启动方式
|
||||
|
||||
uvicorn.run(
|
||||
"app:app",
|
||||
"server:app",
|
||||
host=host,
|
||||
port=port,
|
||||
reload=reload,
|
||||
@@ -62,14 +60,7 @@ def app_run(app_config: dict, default_config: dict):
|
||||
|
||||
def main():
|
||||
freeze_support()
|
||||
# 如果是打包后的可执行文件,调整路径
|
||||
if getattr(sys, "frozen", False):
|
||||
exe_dir = os.path.dirname(sys.executable)
|
||||
if exe_dir not in sys.path:
|
||||
sys.path.insert(0, exe_dir)
|
||||
|
||||
# 启动应用
|
||||
launch(app_run, "development")
|
||||
launch(app_run, "production")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
|
||||
Reference in New Issue
Block a user