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
相关推荐
用户83562907805116 小时前
Python 实现 PDF 文件加密与解密方法
后端·python
用户83562907805116 小时前
使用 Python 冻结与拆分 Excel 窗格教程
后端·python
你好潘先生1 天前
别再记命令了,用 yeero do 说句人话就能跑脚本,而且不烧 token
服务器·python·命令行
Agent_大师1 天前
WebSocket 行情重连成功,K线缺口不会自动消失
python
荣码1 天前
LLM结构化输出:让AI返回JSON而不是废话,我踩了4个坑
java·python
copyer_xyf1 天前
FastAPI 如何连接 MySQL
后端·python
apocelipes2 天前
常用编程语言和库的正则表达式性能对比
c语言·c++·python·性能优化·golang·开发工具和环境
用户8356290780512 天前
使用 Python 在 PDF 中创建与管理书签
后端·python
MeixianAgent2 天前
Python 回测数据入口怎么验?历史 K 线入库前先做 5 个检查
后端·python
咕白m6252 天前
用 Python 实现一键批量查找与替换 Excel 数据
后端·python