Supervisor使用python2.7在Linux Ubuntu中安装
virtualenv:python3.6 + Django2.0 + celery4.2
这是celery.py文件:
from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'savemoney.settings')
app = Celery('savemoney')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
初始化文件:
from __future__ import absolute_import, unicode_literals
from .celery import app as celery_app
__all__ = ['celery_app']
我在本地的celery工人很好,但是当我与主管一起在虚拟环境中运行Celery时:
File "/path/env/mysite/mysite/__init__.py", line 5, in <module>
from .celery import app as celery_app
File "/path/env/mysite/mysite/celery.py", line 7, in <module>
app.config_from_object('django.conf:settings', namespace='CELERY')
TypeError: config_from_object() got an unexpected keyword argument 'namespace'
我的芹菜工人设置:
[program:celery.worker]
directory=/path/env/mysite/
command=/path/env/mysite/celery -A mysite worker -l info
user=root
numprocs=1
autostart=true
autorestart=true
stopsignal=INT
stdout_logfile=/path/env/mysite/celery_worker.log
stdout_logfile_maxbytes=10MB
stdout_logfile_backups=10
redirect_stderr=false
stderr_logfile=/path/env/mysite/celery_worker_err.log
stderr_logfile_maxbytes=10MB
stderr_logfile_backups=10
我尝试过:
1。环境
environment=PATH="/path/env/bin",VIRTUAL_ENV="/path/env/mysite/",PYTHONPATH="/path/env/lib/python:/path/env/lib/python3.6/site-packages"
2.command full_path
command=/path/env/mysite/celery -A mysite worker -l info
主管>状态
supervisor> status
celery.work BACKOFF can't find command '/path/env/mysite/celery'
我这样指代别人的道路:
command=/path/env/mysite/bin/celery -A mysite worker -l info
但是我的项目没有“ bin”目录
我尝试过:
command=/path/env/bin/celery -A mysite worker -l info
错误:
ModuleNotFoundError: No module named 'mysite'
答案 0 :(得分:0)
此问题与主管使用芹菜4.2
我用芹菜3.1.16解决了这个问题