A
A
Alexander2017-07-15 06:16:47
Django
Alexander, 2017-07-15 06:16:47

How to properly set up a daemon for celery?

There is a server with Ubuntu 14.04 and django project 1.10. I follow this manual: tech.willandskill.se/using-celery-with-django-and-...
I inserted this code into /etc/ini.d/celeryd: https://github.com/celery/celery/blob /3.1/extra/ge...
Project settings /home/user_name/djnago_test_celery/djnago_test_celery/settings.py

INSTALLED_APPS = [
   ...
    'django.contrib.sitemaps',
    'djcelery',
    'kombu.transport.django',
]

CELERY_RESULT_BACKEND = "redis://localhost:6379/2"
BROKER_URL = 'redis://localhost:6379/2'

import djcelery

djcelery.setup_loader()

/etc/default/celeryd settings :
# Name of nodes to start, here we have a single node
CELERYD_NODES="worker1"

# Where to chdir at start.
CELERYD_CHDIR="/home/user_name/djnago_test_celery"

# How to call "manage.py celery worker"
CELERYD_MULTI="/home/user_name/Env/djnago_test_celery/bin/python3 $CELERYD_CHDIR/manage.py celery multi"

# Extra arguments to celeryd
CELERYD_OPTS="--time-limit=300 --concurrency=4 --settings=djnago_test_celery.settings"

# Name of the celery config module.
CELERY_CONFIG_MODULE="djnago_test_celery.settings"

# %n will be replaced with the nodename.
CELERYD_LOG_FILE="/home/celery/logs/celery-%n.log"
CELERYD_PID_FILE="/home/celery/logs/celery-run-%n.log"

# Workers should run as an unprivileged user.
CELERYD_USER="user_name"
CELERYD_GROUP="user_name"

# Name of the projects settings module.
export DJANGO_SETTINGS_MODULE="djnago_test_celery.settings"

I run the command sudo /etc/init.d/celeryd start :
celery init v10.1.
Using config script: /etc/default/celeryd
celery multi v3.1.25 (Cipater)
> Starting nodes...
  > [email protected]_name: OK

But the tricks don't work. I read the logs along this path /home/celery/logs/celery-worker1.log , then I look there /var/log/celery/celery.log and see:
[2017-07-14 20:14:54,852: ERROR/MainProcess] consumer: Cannot connect to amqp://guest:**@127.0.0.1:5672//: [Errno 111] Connection refused.
Trying again in 32.00 seconds...

My /etc/default/celeryd settings don't see the project's django settings?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
A
Andrey Burov, 2017-07-15
@kentuck1213

Cannot connect to RabbitMQ, it may not be running.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question