我正在尝试在制作中启动Celery v3.1.25
。正如我在docs中找到的那样
有4种方法可以运行它,其中一种方法是使用Supervisor
。我之前使用过它 - 我的Django项目正在运行它。我做了以下步骤:
1.在official git repo的基础知识上创建了/etc/supervisor/conf.d/mycelery.conf
。
[program:mycelery]
command=celery worker -A cosmetics_crawler_project --loglevel=INFO
directory=/home/chiefir/polo/Cosmo
user=chiefir
numprocs=1
stdout_logfile=/home/chiefir/logs/celery/celery.log
stderr_logfile=/home/chiefir/logs/celery/celery.log
autostart=true
autorestart=true
startsecs=10
stopasgroup=true
priority=1000
2。创建了/etc/supervisor/conf.d/mycelerybeat.conf
:
[program:mycelerybeat]
command=celery beat -A cosmetics_crawler_project --schedule /var/lib/celery/beat.db --loglevel=INFO
directory=/home/chiefir/polo/Cosmo
user=chiefir
numprocs=1
stdout_logfile=/home/chiefir/logs/celery/celerybeat.log
stderr_logfile=/home/chiefir/logs/celery/celerybeat.log
autostart=true
autorestart=true
startsecs=10
stopasgroup=true
priority=999
3。我的/etc/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)
[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
[include]
files = /etc/supervisor/conf.d/*.conf
我在this question发现我必须运行supervisord
才能解雇Celery,但它会抛出错误:
Traceback (most recent call last):
File "/usr/bin/supervisord", line 9, in <module>
load_entry_point('supervisor==3.2.0', 'console_scripts', 'supervisord')()
File "/usr/lib/python2.7/dist-packages/supervisor/supervisord.py", line 367, in main
go(options)
File "/usr/lib/python2.7/dist-packages/supervisor/supervisord.py", line 377, in go
d.main()
File "/usr/lib/python2.7/dist-packages/supervisor/supervisord.py", line 77, in main
info_messages)
File "/usr/lib/python2.7/dist-packages/supervisor/options.py", line 1388, in make_logger
stdout = self.nodaemon,
File "/usr/lib/python2.7/dist-packages/supervisor/loggers.py", line 346, in getLogger
handlers.append(RotatingFileHandler(filename,'a',maxbytes,backups))
File "/usr/lib/python2.7/dist-packages/supervisor/loggers.py", line 172, in __init__
FileHandler.__init__(self, filename, mode)
File "/usr/lib/python2.7/dist-packages/supervisor/loggers.py", line 98, in __init__
self.stream = open(filename, mode)
IOError: [Errno 13] Permission denied: '/var/log/supervisor/supervisord.log'
如果我的项目在python2.7
中运行,为什么它会尝试使用python 3.5
?而且我应该做些什么呢?因为Celery官方文件中有关于此的信息很少。
更新1:如果我以supervisord
用户身份运行root
。
/usr/lib/python2.7/dist-packages/supervisor/options.py:297: UserWarning: Supervisord is running as root and it is searching for its configuration file in default locations (including its current working directory); you probably want to specify a "-c" argument specifying an absolute path to a configuration file for improved security.
'Supervisord is running as root and it is searching '
Error: Another program is already listening on a port that one of our HTTP servers is configured to use. Shut this program down first before starting supervisord.For help, use /usr/bin/supervisord -h
更新2:
错误的主管安装可能存在问题吗?我发现here我已经安装了这样的主管:
sudo apt-get install -y supervisor
pip install supervisor==3.3.3
但我只做了第一部分,并且我的项目有效(显然没有Celery)。我是否还应该使用pip安装主管?
更新3 当我尝试从更新2中获取配方时 - 我收到一条消息,表示无法使用pip install supervisor
和python 3+:/
Supervisor requires Python 2.4 or later but does not work on any version of Python 3. You are using version 3.5.2