You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
40 lines
915 B
40 lines
915 B
#!/usr/bin/env python3
|
|
# -*- coding: utf-8 -*-
|
|
"""
|
|
应用启动脚本
|
|
"""
|
|
import sys
|
|
import os
|
|
from pathlib import Path
|
|
|
|
# 添加项目根目录到Python路径
|
|
project_root = Path(__file__).parent
|
|
sys.path.insert(0, str(project_root))
|
|
|
|
from config import config
|
|
from logger import LoggerManager
|
|
import uvicorn
|
|
|
|
def main():
|
|
"""主函数"""
|
|
# 设置根日志记录器
|
|
LoggerManager.setup_root_logger()
|
|
|
|
# 确保数据目录存在
|
|
config._ensure_directories()
|
|
|
|
print(f"启动 {config.app_name} v{config.app_version}")
|
|
print(f"服务器地址: http://{config.host}:{config.port}")
|
|
print(f"调试模式: {'开启' if config.debug else '关闭'}")
|
|
|
|
# 启动服务器
|
|
uvicorn.run(
|
|
"main:app",
|
|
host=config.host,
|
|
port=config.port,
|
|
reload=config.debug,
|
|
log_level=config.log_level.lower()
|
|
)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|
|
|