How to make redis BROKER_URL dynamic on deployment to AWS instance
I’m deploying a Django app which uses celery task and has redis as the broker backend. I’m using docker for deployment and my production server is an amazon aws instance. The problem I’m facing is that the django settings is different for localhost:
BROKER_URL = 'redis://localhost:6379'
CELERY_RESULT_BACKEND = 'redis://localhost:6379'
and all my unit tests work. For docker it fails unless I change it to
BROKER_URL = 'redis://redis:6379'
CELERY_RESULT_BACKEND = 'redis://redis:6379'
My question is, how do I identify the redis broker url in my deployment server? Will it be
PS: For heroku server there’s an add-on for identifying the redis url call REDISTOGO_URL. Is there something similar for amazon aws server?
One Solution collect form web for “How to make redis BROKER_URL dynamic on deployment to AWS instance”
BROKER_URL = ‘redis://localhost:6379’
CELERY_RESULT_BACKEND = ‘redis://localhost:6379’
The above implies that both redis and celery are running on localhost, the same machine on which your django app is running.
1) Redis is installed on the server, and is running. (sudo service redis-server start)
2) Celery is installed on the server, and is running.
BROKER_URL = ‘redis://redis:6379’
CELERY_RESULT_BACKEND = ‘redis://redis:6379’
If you are using docker, the above implies that there is another docker container which is running redis, and your code container is linked to the redis container with the alias ‘redis’