# README-DEPLOY 仅保留部署命令,按顺序执行。 ## 1. 首次部署(服务器) ```bash cd /www/wwwroot git clone inventory cd inventory python3 -m venv venv source venv/bin/activate pip install -r requirements.txt python init_db.py ``` ## 2. 启动(临时测试) ```bash cd /www/wwwroot/inventory source venv/bin/activate python app.py ``` 访问:`http://127.0.0.1:5000` ## 3. 生产启动(Gunicorn) 先安装: ```bash cd /www/wwwroot/inventory source venv/bin/activate pip install gunicorn ``` 启动: ```bash cd /www/wwwroot/inventory source venv/bin/activate gunicorn -w 2 -b 127.0.0.1:5000 app:app ``` 说明:建议只监听 `127.0.0.1`,由 Nginx/宝塔反向代理。 ## 4. 每次发布更新 ### 本地 ```bash cd C:/Users/BeihongWang/Desktop/inventory git add . git commit -m "feat: your change" git push origin main ``` ### 服务器 ```bash cd /www/wwwroot/inventory git pull origin main source venv/bin/activate pip install -r requirements.txt ``` 然后在宝塔中重启 Python 项目(或重启 Gunicorn 进程)。 ## 5. 数据库备份 ```bash cp /www/wwwroot/inventory/data/inventory.db /www/backup/inventory_$(date +%F).db ``` ## 6. 快速排查 查看服务端口是否监听: ```bash ss -lntp | grep 5000 ``` 本机探活: ```bash curl http://127.0.0.1:5000 ``` 若域名打不开,优先检查: 1. Python 项目是否运行中 2. 域名解析是否生效 3. Nginx/宝塔反向代理是否指向 `127.0.0.1:5000`