Я запускаю Celery через Supervisor на моем удаленном сервере Ubuntu. Это дает мне следующую ошибку в моем celery.log
:
(env) zorgan@app:~/app$ tail /var/log/supervisor/celery.log
password = models.CharField(_('password'), max_length=128)
File "/home/zorgan/app/env/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 1061, in __init__
super(CharField, self).__init__(*args, **kwargs)
File "/home/zorgan/app/env/lib/python3.5/site-packages/django/db/models/fields/__init__.py", line 172, in __init__
self.db_tablespace = db_tablespace or settings.DEFAULT_INDEX_TABLESPACE
File "/home/zorgan/app/env/lib/python3.5/site-packages/django/conf/__init__.py", line 56, in __getattr__
self._setup(name)
File "/home/zorgan/app/env/lib/python3.5/site-packages/django/conf/__init__.py", line 39, in _setup
% (desc, ENVIRONMENT_VARIABLE))
django.core.exceptions.ImproperlyConfigured: Requested setting DEFAULT_INDEX_TABLESPACE,
but settings are not configured. You must either define the environment variable
DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.
, хотя я добавил значение к DJANGO_SETTINGS_MODULE
в моем celery.py
:
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'draft1.settings')
app = Celery("draft1", broker=CELERY_BROKER_URL)
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
Вот мой конфиг /etc/supervisor/conf.d/app-celery.conf
, если вам интересно:
[program:app-celery]
command=/home/zorgan/app/env/bin/celery worker -A draft1 --loglevel=INFO
directory=/home/zorgan/app/draft1
numprocs=1
stdout_logfile=/var/log/supervisor/celery.log
stderr_logfile=/var/log/supervisor/celery.log
autostart=true
autorestart=true
startsecs=10
; Need to wait for currently executing tasks to finish at shutdown.
; Increase this if you have very long running tasks.
stopwaitsecs = 600
stopasgroup=true
; Set Celery priority higher than default (999)
; so, if rabbitmq is supervised, it will start first.
priority=1000
Есть идеи, в чем проблема?
редактировать:
__init__.py:
from __future__ import absolute_import, unicode_literals
#This will make sure the app is always imported when
#Django starts so that shared_task will use this app.
from .celery import app as celery_app
__all__ = ['celery_app']