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
相关推荐
pluvium2713 分钟前
记对 xonsh shell 的使用, 脚本编写, 迁移及调优
linux·python·shell·xonsh
cmpxr_14 分钟前
【C】原码和补码以及环形坐标取模算法
c语言·开发语言·算法
2401_8274999927 分钟前
python项目实战09-AI智能伴侣(ai_partner_5-6)
开发语言·python
PD我是你的真爱粉29 分钟前
MCP 协议详解:从架构、工作流到 Python 技术栈落地
开发语言·python·架构
ZhengEnCi33 分钟前
P2G-Python字符串方法完全指南-split、join、strip、replace的Python编程利器
python
是小蟹呀^1 小时前
【总结】LangChain中工具的使用
python·langchain·agent·tool
宝贝儿好1 小时前
【LLM】第二章:文本表示:词袋模型、小案例:基于文本的推荐系统(酒店推荐)
人工智能·python·深度学习·神经网络·自然语言处理·机器人·语音识别
星晨雪海1 小时前
基于 @Resource 的支付 Service 多实现类完整示例
java·开发语言
王夏奇1 小时前
pythonUI界面弹窗设置的几种办法
python·ui
ACP广源盛139246256731 小时前
破局 Type‑C 切换器痛点@ACP#GSV6155+LH3828/GSV2221+LH3828 黄金方案
c语言·开发语言·网络·人工智能·嵌入式硬件·计算机外设·电脑