I have the following heroku.yml
. The ‘containers’ share the same Dockerfile
:
build:
docker:
web: Dockerfile
celery: Dockerfile
celery-beat: Dockerfile
release:
image: web
command:
- python manage.py migrate users && python manage.py migrate
run:
web: python manage.py runserver 0.0.0.0:$PORT
celery: celery --app=my_app worker --pool=prefork --concurrency=4 --statedb=celery/worker.state -l info
celery-beat: celery --app=my_app beat -l info
I intended to have three containers, but it turns out that Heroku accepts only one web
and the other should be workers
.
So what do I modify at heroku.yml
to have celery
and celery-beat
containers as worker
?
UPDATE
I’ve changed the heroku.yml
to the following, but Heroku keeps only the last worker (i.e. celery beat) and ignores the first worker:
build:
docker:
web: Dockerfile
release:
image: web
command:
- python manage.py migrate users && python manage.py migrate
run:
web: python manage.py runserver 0.0.0.0:$PORT
worker:
command:
- celery --app=my_app worker --pool=prefork --concurrency=4 --statedb=celery/worker.state -l info
image: web
worker:
command:
- celery --app=my_app beat -l info
image: web
What am I missing?
2
Answers
The name
worker
isn’t really important:So just give them different names:
When you scale those processes, use the names
celery_worker
andcelery_beat
.A better option is to combine the celery worker and beat in a single worker / command : (can only be done on Linux os)