无法 运行 主管 Python 3.8

Not able to run Supervisor on Python 3.8

我的 Django 项目是 python 3.8。我添加了芹菜来处理异步功能。在生产中,我打算使用 supervisor。在尝试 运行 主管时,我收到以下错误

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.8 进行设置。不要使用 ubuntu

提供的主管

我正在为我的项目使用 virtualenv,我添加了 requirement.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 中创建文件 例如我有芹菜-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

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

  1. 使用 pip/pip3
  2. 安装
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