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
相关推荐
guygg884 小时前
两轮车MATLAB仿真程序的实现方法
开发语言·matlab
smj2302_796826524 小时前
解决leetcode第3801题合并有序列表的最小成本
数据结构·python·算法·leetcode
yugi9878384 小时前
异构网络下信道环境建模方法及应用
开发语言·网络
AI数据皮皮侠4 小时前
中国乡村旅游重点村镇数据
大数据·人工智能·python·深度学习·机器学习
小北方城市网4 小时前
第 11 课:Python 全栈项目进阶与职业发展指南|从项目到职场的无缝衔接(课程终章・进阶篇)
大数据·开发语言·人工智能·python·数据库架构·geo
Thetimezipsby4 小时前
Go(GoLang)语言基础、知识速查
开发语言·后端·golang
danyang_Q4 小时前
d2l安装(miniforge+cuda+pytorch)
人工智能·pytorch·python
以太浮标4 小时前
华为eNSP模拟器综合实验之-BGP路由协议的配置解析
服务器·开发语言·php
宠..5 小时前
优化文件结构
java·服务器·开发语言·前端·c++·qt
源码梦想家5 小时前
多语言高性能异步任务队列与实时监控实践:Python、Java、Go、C++实战解析
开发语言·python