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
相关推荐
CTA终结者26 分钟前
期货量化主力换月程序怎么移仓:天勤 underlying_symbol 与任务切换
python·区块链
huangdong_28 分钟前
1688商品图片采集技术解析:登录态处理与SKU图自动分类
开发语言
马士兵教育28 分钟前
Java还有前景吗?Java+AI大模型学习路线及项目?
java·人工智能·python·学习·机器学习
chase_my_dream39 分钟前
C++ + SLAM 高频面试问题整理
开发语言·c++·面试
KaMeidebaby1 小时前
卡梅德生物技术快报|纯化重组蛋白实操详解
人工智能·python·tcp/ip·算法·机器学习
Cloud_Shy6181 小时前
解读《Effective Python 3rd Edition》:从练气到老魔(第五章 Item 30 - 32)
开发语言·人工智能·笔记·python·学习方法
天佑木枫1 小时前
15天Python入门系列 · 序
开发语言·python
happylifetree1 小时前
Python017-第二章15.数据容器-dict常用操作
python
装不满的克莱因瓶2 小时前
了解 LangChain 中的 LLM 与 ChatModel 的差异
人工智能·python·ai·langchain·llm·agent·chatmodel
宋拾壹2 小时前
同时添加多个类目
android·开发语言·javascript