我正在尝试在生产中启动Celery v3.1.25
。 正如我在docs中发现的那样,有4种方法可以运行它,其中一种是使用Supervisor
。 我以前用过它-我的Django项目正在使用它。 我做了以下步骤:
1.根据官方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
在这个问题中 ,我发现我必须运行supervisord
才能解雇芹菜,但是会引发错误:
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'
如果我在python 3.5
运行我的项目,为什么它会尝试使用python2.7
呢? 我应该做些什么,因为芹菜官方文档中只有很少的信息。
更新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:
错误的主管安装可能会出现问题吗? 我在这里发现我有这样的安装主管:
sudo apt-get install -y supervisor
pip install supervisor==3.3.3
但是,我只完成了第一部分,并且我的项目也就完成了(显然没有Celery)。 我还应该使用pip安装主管吗?
更新3当我尝试从更新2配方时-我收到一条消息,指出无法将python 3+的pip install supervisor
使用:/
Supervisor requires Python 2.4 or later but does not work on any version of Python 3. You are using version 3.5.2