centos7 部署flask项目之 systemd--gunicorn

本文介绍了如何在 CentOS 7 系统上利用 systemd 配置并使用 gunicorn 来部署 Flask 项目。内容包括查看 gunicorn 进程、启动和停止 gunicorn 以及 nginx 服务,编写和编辑 systemd 服务文件,并通过 systemctl 命令启动和检查 gunicorn 服务的状态。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

systemctl


部署flask项目gunicorn后systemd来管理server
systemctl start **.service 封装 workon venv 和 gunicorn -b 127.0.0.1:5000 manage:app 两个命令
not source venv/bin/activce和指定path启动guncorn

gunicorn的基本常用使用命令

  1. ps -ef | grep gunicorn
  2. gunicorn manage:app -b 127.0.0.1:5000
  3. killall gunicorn 直接全部kill所有 gunicorn进程
    killall nginx

cd /etc/systemd/system

  1. vi gunicorn.service
    [Unit]
    Description=Gunicorn instance to server sql_on_log
    After=network.target

    [Service]
    User=root
    PrivateTmp=true
    WorkingDirectory=/opt/essql/api
    #Environment=“PATH=/home/python/venv/bin”
    ExecStart=/home/python/venv/bin/gunicorn --bind 127.0.0.1:5000 manage:app

    [Install]
    WantedBy=multi-user.target

  2. systemctl daemon-reload
    每次service文件写完或者修改完都需要reload加载

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值