Alireza Savand
Alireza Savand

Reputation: 3478

How to deploy Django with Channels and Celery on Heroku?

How one deploys the following stack on Heroku platform ?

The limitation surely is on the Procfile.

To deploy Django with Celery it would be something like:

web: gunicorn project.wsgi:application
worker: celery worker --app=project.taskapp --loglevel=info

While deploying Django with Channels:

web: daphne project.asgi:channel_layer --port $PORT --bind 0.0.0.0 -v2
worker: python manage.py runworker -v2

The web process can use ASGI, but the worker process will be used by Channels and I don't see how Celery can be started alongside it.

Upvotes: 3

Views: 937

Answers (1)

Daniel Roseman
Daniel Roseman

Reputation: 599450

You can have as many entries in the Procfile as you like. The only one that is special is "web", because that's the one Heroku expects to receive web requests, and the only one it will start automatically for you. You can use your own names for the rest:

web: gunicorn project.wsgi:application
celeryworker: celery worker --app=project.taskapp --loglevel=info
channelsworker: python manage.py runworker -v2

Now you can do heroku ps:scale celeryworker=1 and heroku ps:scale channelsworker=1 to start the other two processes.

See the Heroku Procfile docs for more information.

Upvotes: 5

Related Questions