S
S
skorpix2015-11-03 14:45:21
Django
skorpix, 2015-11-03 14:45:21

There are two sites on one server. Both need celery. How to setup?

Good day.
There are two independent sites on django. Both are running on the same server, but under different users. How to set up celery on each project? Need to create two databases in redis? Or run two processes on different ports? Or what? I understand this little and so far I do not grasp the essence of what is needed for what.
PS I once tried to run two celery, but the tasks were somehow strangely executed, as if tasks from one site were being executed on the database of the second site.

Answer the question

In order to leave comments, you need to log in

3 answer(s)
G
GoTLiuM InSPiRiT, 2015-11-12
@skorpix

project #1
project #2
BROKER_URL = 'redis://localhost:6379/1'

A
andrewshkovskii, 2015-11-12
@andrewshkovskii

1. Set up celery properly for django
2. Use redis to store tasks in celery (no need to use sql db to store celery queues)
3. Use supervisor to run celery.
First, show me the configurations for celery for two of your projects.

S
skorpix, 2015-11-12
@skorpix

andrewshkovskii settings are for the first site.

BROKER_URL = 'redis://localhost:6379/0'
CELERYD_CONCURRENCY = 8
CELERYD_MAX_TASKS_PER_CHILD = 100
CELERY_EMAIL_TASK_CONFIG = {
    'rate_limit': '6/m'
}

celery is started via supervisor
[program:celery]
command=/home/%(user)s/.env/bin/python /home/%(user)s/current/manage.py celery worker -l INFO
directory=/home/%(user)s/current
environment=DJANGO_SETTINGS_MODULE="project.settings.%(environment)s"
autostart=true
autorestart=true
redirect_stderr=true
stdout_logfile=/home/%(user)s/log/celery.log

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question