python生成环境部署

1.安装

bash 复制代码
pip install gunicorn
which gunicorn  #获取到path  /usr/local/python3.10/bin/gunicorn
bash 复制代码
vim /etc/systemd/system/文件名.service
bash 复制代码
[Unit]
Description=Gunicorn Flask Service
After=network.target

[Service]
Type=simple
User=root
WorkingDirectory=/opt/fmzhang/python/akamai
ExecStart=/usr/local/python3.10/bin/gunicorn 文件名:app \
  -b 0.0.0.0:7901 \
  -w 3 \
  -k gthread \
  --threads 10 \
  --timeout 15
Restart=always
RestartSec=3

[Install]
WantedBy=multi-user.target

启动 & 设置开机自启

bash 复制代码
systemctl daemon-reload
systemctl start 文件名
systemctl enable 文件名
journalctl -u 文件名 -f  看日志

改了.py,重启服务

bash 复制代码
systemctl restart 文件名
systemctl status 文件名

常见命令

bash 复制代码
#不中断请求
systemctl reload 
# 启动
systemctl start 

# 停止
systemctl stop 

# 重启(代码更新最常用)
systemctl restart 

# 看状态
systemctl status 

# 实时看日志(排错神器)
journalctl -u 文件名 -f
相关推荐
用户8356290780511 分钟前
使用 Python 在 Excel 图表中添加趋势线与回归方程
后端·python
特立独行的猫A14 分钟前
一份 Markdown 发十个平台:cspub 一稿多投
java·后端·python
深蓝AI31 分钟前
HTTPX 超时 1 秒,接口为何还能跑 2.4 秒?
python
CyrusYiVPP37 分钟前
哪个用户会再来买?RFM模型+plotly画出用户分层,数据分析实战第2期
人工智能·python
李帅5152 小时前
用 CPU 做发票识别:从 OCR 文本行到结构化明细表的 4 个硬骨头
python
happylifetree3 小时前
Python79:核心语法-面向对象基础-实例方法
python
nice_lcj5203 小时前
ThreadLocal 入门:它是怎么隔离数据的、为什么会导致内存泄漏
java·开发语言·后端·面试·并发编程·内存泄漏·threadlocal
贝壳6904 小时前
bool-hybrid-array 9.13.6 偷偷加了个"按键自动升序"的字典,我翻出来测了下
python
紧跟先前的步伐4 小时前
Go AI Agent 实战 28|Agent 的预算、超时与停止条件
开发语言·人工智能·后端·ai·golang
艺杯羹4 小时前
MCP本地服务集成避坑:从Stdio管道僵死到双向JSON-RPC稳健通信
人工智能·python·ai·系统架构·大语言模型·ai编程·mcp