【问题标题】:Not able to run Supervisor on Python 3.8无法在 Python 3.8 上运行 Supervisor
【发布时间】:2020-07-02 16:17:06
【问题描述】:

我的 Django 项目在 python 3.8 中。我添加了芹菜来处理异步功能。在生产中,我计划使用主管。在尝试运行主管时出现以下错误

pkg_resources.DistributionNotFound: The 'supervisor==3.3.1' distribution was not found and is required by the application

我尝试使用 pip 安装 3.3.1,但 python 3.8 不支持它。

我尝试使用http://supervisord.org/,但文档中关于如何设置它在服务器启动时自动运行的内容含糊不清。如何在后台启动、停止和重新启动。

【问题讨论】:

    标签: python-3.x celery supervisord


    【解决方案1】:

    我能够使用 Python 3.8 进行设置。不要使用ubuntu提供的supervisor

    我正在为我的项目使用 virtualenv,并添加了 require.txt

    supervisor==4.2.0
    

    检查目录 /var/log/supervisord 是否存在。如果没有,则创建此目录。它将用于主管 sock 文件和日志

    检查 /etc/supervisor/supervisord.conf 文件是否存在。如果没有,则创建具有以下内容的文件

    [unix_http_server]
    file=/var/run/supervisor.sock   ; (the path to the socket file)
    chmod=0700                       ; sockef file mode (default 0700)
    
    [supervisord]
    logfile=/var/log/supervisor/supervisord.log ; (main log file;default $CWD/supervisord.log)
    pidfile=/var/run/supervisord.pid ; (supervisord pidfile;default supervisord.pid)
    childlogdir=/var/log/supervisor            ; ('AUTO' child log dir, default $TEMP)
    
    ; the below section must remain in the config file for RPC
    ; (supervisorctl/web interface) to work, additional interfaces may be
    ; added by defining them in separate rpcinterface: sections
    [rpcinterface:supervisor]
    supervisor.rpcinterface_factory = supervisor.rpcinterface:make_main_rpcinterface
    
    [supervisorctl]
    serverurl=unix:///var/run/supervisor.sock ; use a unix:// URL  for a unix socket
    
    ; The [include] section can just contain the "files" setting.  This
    ; setting can list multiple files (separated by whitespace or
    ; newlines).  It can also contain wildcards.  The filenames are
    ; interpreted as relative to this file.  Included files *cannot*
    ; include files themselves.
    
    [include]
    files = /etc/supervisor/conf.d/*.conf
    
    

    完成后,在 /etc/supervisor/conf.d 中创建文件 例如我有 celery-worker.conf

    [program:celeryworkerdemo]
    command=/home/ubuntu/venv/bin/celery -A celeryworkerdemo worker -l debug
    directory=/home/ubuntu/celeryworkerdemo/
    user=ubuntu
    numprocs=1
    stdout_logfile=/home/ubuntu/logs/celerylogs/celeryworkerdemo_worker.log
    stderr_logfile=/home/ubuntu/logs/celerylogs/celeryworkerdemo_worker_err.log
    autostart=true
    autorestart=true
    startsecs=10
    stopwaitsecs = 600
    killasgroup=true
    priority=998
    
    

    完成后,运行以下命令

    sudo systemctl daemon-reload
    sudo systemctl enable supervisord && sudo systemctl start supervisors
    

    运行以下命令查看状态

    sudo systemctl status supervisord
    

    【讨论】:

      【解决方案2】:

      我正在按照以下步骤在 3.8 中运行主管

      1. 使用 pip/pip3 安装
      pip3 install supervisor
      
      1. 修改主管服务。将路径 /usr/local/supervisord 更改为 /usr/local/bin/supervisord
      vim /lib/systemd/system/supervisor.service
      
      1. 重新加载守护进程
      sudo systemctl daemon-reload
      
      1. 启动服务。
      sudo systemctl start supervisor.service
      

      【讨论】:

        猜你喜欢
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 1970-01-01
        • 2018-11-17
        • 2016-07-23
        • 2015-10-09
        • 1970-01-01
        相关资源
        最近更新 更多