Ich versuche, djcelery
in meiner Django-Anwendung von rabbitmq
Server Ubuntu 14.04
Server gehostet.Django: Sellerie Worker wird nicht gestartet (ohne Fehler)
Beim Versuch Sellerie im Debug-Modus zu beginnen: python manage.py celery worker -B -E --loglevel=debug
wird Befehl mit folgenden Ausgabe beendet zu werden:
[2016-03-24 12:16:09,568: DEBUG/MainProcess] | Worker: Preparing bootsteps.
[2016-03-24 12:16:09,571: DEBUG/MainProcess] | Worker: Building graph...
[2016-03-24 12:16:09,572: DEBUG/MainProcess] | Worker: New boot order: {Timer, Hub, Queues (intra), Pool, Autoscaler, StateDB, Autoreloader, Beat, Consumer}
[2016-03-24 12:16:09,575: DEBUG/MainProcess] | Consumer: Preparing bootsteps.
[2016-03-24 12:16:09,576: DEBUG/MainProcess] | Consumer: Building graph...
[2016-03-24 12:16:09,577: DEBUG/MainProcess] | Consumer: New boot order: {Connection, Events, Mingle, Tasks, Control, Agent, Heart, Gossip, event loop}
<user>@<gce.host>:~/path/to/my/project$
Was möglicherweise die Ursache für dieses Problem sein kann? Das gleiche Setup läuft auf meinem lokalen Ubuntu-Rechner und soweit ich mich erinnere, habe ich alle Schritte auf meinem Cloud-Server verfolgt.
Zusätzliche Informationen: Dinge, die ich überprüft
- RabbitMQ Server läuft gut. Die Ausgabe von Log-Datei:
= INFO REPORT ==== 24-Mar-2016 :: 17: 02: 14 === Annahme AMQP Verbindung < 0.209.0> (127.0.0.1:42326 - > 127.0.0.1:5672)
= INFO REPORT ==== 24-Mar-2016 :: 17: 02: 14 === AMQP Verbindung < 0.219.0> (127.0.0.1:42327 Annahme -> 127.0 .0.1: 5672)
= INFO REPORT ==== 24.03.2016 :: 17: 02: 17 === Annahme der AMQP-Verbindung < 0.229.0> (127.0.0.1:42328 -> 127.0.0.1 : 5672)
- Port
5672
ist auf meinem Computer geöffnet. Ich habe auch Port geöffnet:tcp:5555
,tcp:4369
,tcp:15672
,tcp:5671
wie erwähnt here (auf der sicheren Seite zu sein).
Sellerie Konfiguration in meinem Projekt:
installiert celery
und django-celery
Paket. Erstellt rabbitMQ
Benutzer und legen Sie die Berechtigungen mit den Befehlen:
sudo rabbitmqctl add_user <user> <password>
sudo rabbitmqctl set_permissions -p/<user> ".*" ".*" ".*"
In settings.py Datei, ich habe hinzugefügt:
import djcelery
djcelery.setup_loader()
MIDDLEWARE_CLASSES = [ 'django.middleware.transaction.TransactionMiddleware',
..]
INSTALLED_APPS = ['djcelery',
..]
Inhalt des celery.py ist als:
from __future__ import absolute_import
import os
from datetime import timedelta
from celery import Celery
from celery.schedules import crontab
from django.conf import settings
# set the default Django settings module for the 'celery' program.
os.environ.setdefault('DJANGO_SETTINGS_MODULE', '<my_project>.settings')
app = Celery('<my_project>')
# Using a string here means the worker will not have to
# pickle the object when using Windows.
app.config_from_object('<my_project>.settings')
# app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
app.conf.update(
CELERY_ACCEPT_CONTENT = ['json'],
CELERY_TASK_SERIALIZER = 'json',
CELERY_RESULT_SERIALIZER = 'json',
BROKER_URL = 'amqp://<user>:<password>@localhost:5672//',
# BROKER_URL = 'django://',
CELERY_RESULT_BACKEND = "amqp",
CELERY_IMPORTS = ("<module1>.tasks", "<module2>.tasks.tasks", "<module3>.tasks.tasks"),
CELERY_ALWAYS_EAGER = False,
# CELERY_RESULT_BACKEND='djcelery.backends.database:DatabaseBackend',
# CELERY_TIMEZONE = 'Europe/London'
CELERY_TIMEZONE = 'UTC',
CELERYBEAT_SCHEDULE = {
'debug-test': {
'task': '<module1>.tasks.test_celery',
'schedule': timedelta(seconds=5),
# 'args': (1, 2)
},
}
)