区分测试生产环境部署配置
This commit is contained in:
@@ -0,0 +1,25 @@
|
||||
#!/bin/bash
|
||||
|
||||
# 确保进入工作目录
|
||||
cd /app
|
||||
|
||||
echo "=== [Step 1] 检查并初始化数据库 ==="
|
||||
# 使用 || true 确保即使命令报错(例如migrations文件夹已存在)也不会中断脚本
|
||||
flask db init || true
|
||||
flask db migrate || true
|
||||
flask db upgrade || true
|
||||
|
||||
# (可选) 每次重启尝试初始化数据,如果已存在则会被代码逻辑跳过
|
||||
flask admin init || true
|
||||
|
||||
echo "=== [Step 2] 启动服务 (开发模式) ==="
|
||||
|
||||
# [优化] 增加 --reload 参数
|
||||
# 配合 docker-compose 的 volumes,当检测到代码变化时,Gunicorn 会自动重启 worker
|
||||
# access-logfile - 表示将日志输出到控制台
|
||||
exec gunicorn --bind 0.0.0.0:5000 \
|
||||
--workers 2 \
|
||||
--reload \
|
||||
--access-logfile - \
|
||||
--error-logfile - \
|
||||
app:app
|
||||
Reference in New Issue
Block a user