mirror of
https://github.com/countbot-ai/CountBot.git
synced 2026-09-14 20:46:47 +08:00
优化(启动脚本): 改进启动体验
- start_app.py: 浏览器延迟从2秒改为15秒,确保服务器完全启动 - start_app.py: 添加文档注释和参数说明
This commit is contained in:
+1
-1
@@ -1,5 +1,5 @@
|
||||
# ============================================
|
||||
# CountBot v0.3.1 依赖配置
|
||||
# CountBot 依赖配置
|
||||
# ============================================
|
||||
|
||||
# ── 核心框架 ──────────────────────────────
|
||||
|
||||
+8
-2
@@ -33,8 +33,14 @@ from backend.utils.ssl_compat import ensure_ssl_certificates
|
||||
ensure_ssl_certificates()
|
||||
|
||||
|
||||
def open_browser_delayed(url: str, delay: float = 2.0) -> None:
|
||||
"""延迟打开浏览器"""
|
||||
def open_browser_delayed(url: str, delay: float = 15.0) -> None:
|
||||
"""
|
||||
延迟打开浏览器
|
||||
|
||||
Args:
|
||||
url: 要打开的 URL 地址
|
||||
delay: 延迟时间(秒),默认 15 秒,确保服务器完全启动
|
||||
"""
|
||||
def _open():
|
||||
import time
|
||||
time.sleep(delay)
|
||||
|
||||
+11
-3
@@ -29,11 +29,19 @@ sys.path.insert(0, str(project_root))
|
||||
|
||||
|
||||
def main():
|
||||
"""启动应用(开发模式)"""
|
||||
"""
|
||||
启动应用(开发模式)
|
||||
|
||||
功能:
|
||||
- 启动 FastAPI 应用服务器(开发模式)
|
||||
- 启用热重载,文件更改自动重启
|
||||
- 显示本地和网络访问地址
|
||||
- 监控 backend 目录的文件变化
|
||||
"""
|
||||
import uvicorn
|
||||
from loguru import logger
|
||||
|
||||
# 配置
|
||||
# 读取配置
|
||||
host = os.getenv("HOST", "127.0.0.1")
|
||||
port = int(os.getenv("PORT", "8000"))
|
||||
|
||||
@@ -83,7 +91,7 @@ def main():
|
||||
port=port,
|
||||
reload=True, # 开发模式启用热重载
|
||||
reload_dirs=["backend"], # 监控 backend 目录
|
||||
log_level="debug"
|
||||
log_level="debug" # 开发模式使用 debug 日志级别
|
||||
)
|
||||
except KeyboardInterrupt:
|
||||
logger.info("Received keyboard interrupt")
|
||||
|
||||
Reference in New Issue
Block a user