【问题标题】:"module not found" when running Celery with supervisor使用主管运行 Celery 时出现“找不到模块”
【发布时间】:2020-07-30 13:22:06
【问题描述】:

我正在尝试使用主管在 django 中运行 celery。

supervisor_celery.conf

[program:supervisor-celery]
command=/home/user/project/virtualenvironment/bin/celery worker -A project --loglevel=INFO
directory=/home/user/project/project
user=nobody
numprocs=1
stdout_logfile=/home/user/project/logs/celery.log
stderr_logfile=/home/user/project/logs/celery.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
stopasgroup=true
priority=1000

在运行主管时,我在日志文件中收到以下错误:-

Unable to load celery application.
The module project was not found.

项目结构是

project
|-project
   |-settings
       |-production.py
   |-__init__.py
   |-celery.py
   |-urls.py
   |-wsgi.py
|-app

__init__.py的内容是:-

from __future__ import absolute_import, unicode_literals
from .celery import app as celery_app
__all__ = ('celery_app',)

celery.py的内容是

from __future__ import absolute_import, unicode_literals
import os
from celery import Celery
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'project.settings.production')
app = Celery('project')
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()

如果有人能告诉我为什么它不起作用会很有帮助?

【问题讨论】:

    标签: django celery supervisord django-supervisor


    【解决方案1】:

    看来你的目录错误(在supervisor conf中),应该是

    directory=/home/user/project
    

    【讨论】:

      猜你喜欢
      • 2019-08-27
      • 1970-01-01
      • 1970-01-01
      • 2018-06-09
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2023-02-01
      • 1970-01-01
      相关资源
      最近更新 更多