Django/Celery/Droplet:启动芹菜失败,但使用相同的脚本手动工作(AppRegistryNotReady:应用程序尚未加载。



我可以用我的celery_init.sh呼叫工人。它接收任务并以我期望的方式处理它们,正如花所证实的那样。我无法让主管使用相同的脚本自动启动芹菜。

terminal$ ./celery_init.sh完美运作

terminal$ sudo supervisorctl restart celery失败如下

追踪

[2017-07-18 21:07:28,475: CRITICAL/MainProcess] Unrecoverable error: AppRegistryNotReady("Apps aren't loaded yet.",)
Traceback (most recent call last):
File "/home/realestateleads/local/lib/python2.7/site-packages/celery/worker/worker.py", line 203, in start
self.blueprint.start(self)
File "/home/realestateleads/local/lib/python2.7/site-packages/celery/bootsteps.py", line 115, in start
self.on_start()
File "/home/realestateleads/local/lib/python2.7/site-packages/celery/apps/worker.py", line 143, in on_start
self.emit_banner()
File "/home/realestateleads/local/lib/python2.7/site-packages/celery/apps/worker.py", line 158, in emit_banner
' n', self.startup_info(artlines=not use_image))),
File "/home/realestateleads/local/lib/python2.7/site-packages/celery/apps/worker.py", line 221, in startup_info
results=self.app.backend.as_uri(),
File "/home/realestateleads/local/lib/python2.7/site-packages/kombu/utils/objects.py", line 44, in __get__
value = obj.__dict__[self.__name__] = self.__get(obj)
File "/home/realestateleads/local/lib/python2.7/site-packages/celery/app/base.py", line 1182, in backend
return self._get_backend()
File "/home/realestateleads/local/lib/python2.7/site-packages/celery/app/base.py", line 900, in _get_backend
self.loader)
File "/home/realestateleads/local/lib/python2.7/site-packages/celery/app/backends.py", line 65, in by_url
return by_name(backend, loader), url
File "/home/realestateleads/local/lib/python2.7/site-packages/celery/app/backends.py", line 45, in by_name
cls = symbol_by_name(backend, aliases)
File "/home/realestateleads/local/lib/python2.7/site-packages/kombu/utils/imports.py", line 56, in symbol_by_name
module = imp(module_name, package=package, **kwargs)
File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
__import__(name)
File "/home/realestateleads/local/lib/python2.7/site-packages/django_celery_results/backends/__init__.py", line 4, in <module>
from .database import DatabaseBackend
File "/home/realestateleads/local/lib/python2.7/site-packages/django_celery_results/backends/database.py", line 7, in <module>
from ..models import TaskResult
File "/home/realestateleads/local/lib/python2.7/site-packages/django_celery_results/models.py", line 17, in <module>
class TaskResult(models.Model):
File "/home/realestateleads/local/lib/python2.7/site-packages/django/db/models/base.py", line 110, in __new__
app_config = apps.get_containing_app_config(module)
File "/home/realestateleads/local/lib/python2.7/site-packages/django/apps/registry.py", line 247, in get_containing_app_config
self.check_apps_ready()
File "/home/realestateleads/local/lib/python2.7/site-packages/django/apps/registry.py", line 125, in check_apps_ready
raise AppRegistryNotReady("Apps aren't loaded yet.")
AppRegistryNotReady: Apps aren't loaded yet.

主管配置文件

; =========================
;  celery worker supervisor 
; =========================
[program:celery]
command=/home/realestateleads/bin/celery_init.sh
directory=/home/realestateleads/RealEstateLeads/DjangoRealEstateLeads
user=nobody
numprocs=1
stdout_logfile=/home/realestateleads/logs/celery/worker.log
stderr_logfile=/home/realestateleads/logs/celery/worker_err.log
autostart=true
autorestart=true
startsecs=10
stopwaitsecs = 600
killasgroup=true
priority=1000

celery_init.sh

export SECRET_KEY='MYSECRETKEYHERE'
/home/realestateleads/bin/celery --app=base.celeryapp:app worker --loglevel=INFO -n worker.%%h

celeryapp.py

import os
from celery import Celery, shared_task
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'base.settings')
app = Celery('DjangoRealEstateLeads')
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('django.conf:settings', namespace='CELERY')
app.autodiscover_tasks()
if __name__ == '__main__':
app.start()

@app.task(bind=True)
def debug_task(self):
print('Request: {0!r}'.format(self.request))

问题出在我的主管配置文件中。

我不得不将user=nobody更改为user=realestateleads(即:我的用户名(。我不知道为什么;权限令人困惑!它有效。

相关内容

  • 没有找到相关文章

最新更新