title: How do I change my CELERY_BROKER_URL in an already daemonized Celery process?
body: <p>I'm daemonizing my Celery worker using Supervisord. The issue is I had a typo in my <code>CELERY_BROKER_URL</code> and the worker is not properly connecting to RabbitMQ.</p>
  
  <p>When I run <code>celery -A mysite report</code> it shows the old environment variable.</p>
  
  <p>My <code>/etc/supervisor/conf.d/celery.conf</code> file does not include the environment variables:</p>
  
  <pre><code>[program:celery]
  command=/webapps/mysite/scripts/celery/celery_start
  
  autostart=true
  autorestart=true
  
  user=myuser
  
  stdout_logfile=/webapps/mysite/logs/celery.log
  redirect_stderr = true
  </code></pre>
  
  <p>The environment variables are picked up via my virtual environment in the <code>celery_start</code> script:</p>
  
  <pre><code>#!/bin/sh
  
  DJANGODIR=/webapps/mysite/mysite
  
  # Activate the virtual environment.
  cd $DJANGODIR
  . /webapps/mysite/bin/activate
  . /webapps/mysite/bin/postactivate
  
  # Programs meant to be run under supervisor should not daemonize themselves
  # (do not use --daemon).
  exec celery -A mysite worker -E -l info --concurrency=2
  </code></pre>
  
  <p>When I check the <code>CELERY_BROKER_URL</code> environment variable after activating the environment it is correct. I've tried <code>supervisorctl restart celery</code> which doesn't pick up the new environment variable (<code>celery -A mysite report</code> shows the old <code>CELERY_BROKER_URL</code>). I've tried <code>supervisorctl shutdown</code> and then <code>supervisord</code> which also won't pick up the new environment variable.</p>
  
  <p>When I run <code>ps aux | grep 'celery worker'</code> I don't see anything, presumably because Celery is daemonized by Supervisor, so I'm not sure of a way to completely destroy the current Celery process.</p>
  
  <p>No matter what, it feels like Celery is not picking up the new environment variable. How could I make this happen?</p>
  
  <p>[EDIT]
  My Celery settings in <code>settings.py</code> are as follows:</p>
  
  <pre><code># Celery settings.
  CELERY_BROKER_URL = os.environ.get(
      'BROKER_URL', 'amqp://guest:guest@127.0.0.1//')
  CELERY_TASK_SOFT_TIME_LIMIT = 60
  CELERY_RESULT_BACKEND = 'django-db'
  </code></pre>
  
  <p>And my <code>mysite/celery.py</code> file is:</p>
  
  <pre><code>from __future__ import absolute_import, unicode_literals
  import os
  from celery import Celery
  
  # set the default Django settings module for the 'celery' program.
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'settings.local')
  
  APP = Celery('mysite')
  
  # Using a string here means the worker doesn't have to serialize
  # the configuration object to child processes.
  # - namespace='CELERY' means all celery-related configuration keys
  #   should have a `CELERY_` prefix.
  APP.config_from_object('django.conf:settings', namespace='CELERY')
  
  # Load task modules from all registered Django app configs.
  APP.autodiscover_tasks()
  
  
  @APP.task(bind=True)
  def debug_task(self):
      print('Request: {0!r}'.format(self.request))
  </code></pre>