• supervisor部署python项目


    1. 安装supervisor

    supervisor可以帮助我们盯着python程序,哪怕是python程序不小心挂掉了,supervisor也会帮我们立即启起来,首先开始安装

    pip install supervisor
    

    2. 生成配置文件

    supervisor通过配置文件来控制python文件

     echo_supervisord_conf > ./supervisord.conf
    

    3. 修改配置文件

    比如,我的目的是让supervisor保障/test/下的test1.py和test2.py能持续运行

    首先通过which python确定使用哪个python

    >>> which python
    /opt/conda/envs/py374/bin/python
    
    ……
    ;[include]
    ;files = relative/directory/*.ini
    
    # 直接跳到最后添加如下代码(我的python绝对路径是

    /opt/conda/envs/py374/bin/python

    )
    
    #项目1
    [program:partion-1] # 给个名字
    directory=/test/ # python程序所在目录
    command= /opt/conda/envs/py374/bin/python test1.py
    # 开始等待时间
    startsecs=0
    # 停止等待时间
    stopwaitsecs=0
    autorestart=true
    # 设置为守护进程
    daemon=true
    
    #项目2
    [program:partion-2] # 给个名字
    directory=/test/ # python程序所在目录
    command= /opt/conda/envs/py374/bin/python test2.py
    # 开始等待时间
    startsecs=0
    # 停止等待时间
    stopwaitsecs=0
    autorestart=true
    # 设置为守护进程
    daemon=true
    

    4. 首次启动

    supervisord -c supervisord.conf
    

     此时test1.py, test2.py 已经开始运行了

    5. 后续操作

    supervisorctl -c supervisord.conf

    停止程序:stop all

    启动程序:start all

    重载:reload

  • 相关阅读:
    vue去除#号tomcat配置
    vscode配置
    git忽略想要提交的文件
    vue-cli配置移动端自适应
    远程调试工具 -- weinre
    将博客搬至CSDN
    错误:this dependency was not found:'element-ui/lib/theme-chalk/index.css'。。。。。。。
    win上java1.7和1.8版本修改环境变量无效.md
    mysql 事务
    mysql 函数
  • 原文地址:https://www.cnblogs.com/niulang/p/14990875.html
Copyright © 2020-2023  润新知