title: How to configure Celery Daemon with Django
body: <p>From what I can tell, there are two documents describing how to set up celery. There's "<a href="http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html" rel="noreferrer">Running the worker as a daemon</a>" and there's "<a href="http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html" rel="noreferrer">First steps with Django</a>".</p>
  
  <p>In the Django docs, it says:</p>
  
  <blockquote>
    <p>We also add the Django settings module as a configuration source for Celery. This means that you don’t have to use multiple configuration files, and instead configure Celery directly from the Django settings.</p>
  </blockquote>
  
  <p>Which sounds <strong>awesome</strong>. However, from what I can tell, these are the files that are needed for a complete Celery daemonization:</p>
  
  <ul>
  <li><code>/etc/init.d/celeryd</code></li>
  <li><code>/etc/defaults/celery</code></li>
  <li><code>/my-proj/celery.py</code></li>
  <li><code>/my-proj/__init__.py</code></li>
  </ul>
  
  <p>And possibly:</p>
  
  <ul>
  <li><code>/my-proj/settings.py</code></li>
  </ul>
  
  <p>Boy that's a lot of files. I think I've got them all set up properly:</p>
  
  <ul>
  <li><code>/etc/init.d/celeryd</code> has <a href="https://github.com/celery/celery/blob/3.1/extra/generic-init.d/celeryd" rel="noreferrer">the default init.d script</a> provided by celery.</li>
  <li><p><code>/etc/defaults/celery</code> has almost nothing. Just a pointer to my app:</p>
  
  <pre><code>export DJANGO_SETTINGS_MODULE='cl.settings'
  </code></pre></li>
  <li><p><code>/my-proj/celery.py</code> has the recommended file from the <a href="http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html" rel="noreferrer">First Steps with Django</a>:</p>
  
  <pre><code>from __future__ import absolute_import
  
  import os
  
  from celery import Celery
  
  # set the default Django settings module for the 'celery' program.
  os.environ.setdefault('DJANGO_SETTINGS_MODULE', 'proj.settings')
  
  from django.conf import settings  # noqa
  
  app = Celery('proj')
  
  # Using a string here means the worker will not have to
  # pickle the object when using Windows.
  app.config_from_object('django.conf:settings')
  app.autodiscover_tasks(lambda: settings.INSTALLED_APPS)
  </code></pre></li>
  <li><p><code>/my-proj/__init__.py</code> has the recommended code from the <a href="http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html" rel="noreferrer">First Steps with Django</a>:</p>
  
  <pre><code>from __future__ import absolute_import
  
  # This will make sure the app is always imported when
  # Django starts so that shared_task will use this app.
  from .celery import app as celery_app
  </code></pre></li>
  </ul>
  
  <p>And I have all the celery-related settings like the following in my <code>settings.py</code> file:</p>
  
  <pre><code>CELERY_BIN = '/var/www/.virtualenvs/my-env/bin/celery'
  CELERYD_USER = 'www-data'
  CELERYD_GROUP = 'www-data'
  CELERYD_CONCURRENCY = 20
  BROKER_URL = 'redis://'
  BROKER_POOL_LIMIT = 30
  </code></pre>
  
  <p>Yet, when I start celery using <code>sudo service celeryd start</code>, it doesn't work. Instead, it's clear that it hasn't picked up my settings from my Django project, because it says:</p>
  
  <pre><code>Nov 05 20:51:59 pounamu celeryd[30190]: celery init v10.1.
  Nov 05 20:51:59 pounamu celeryd[30190]: Using config script: /etc/default/celeryd
  Nov 05 20:51:59 pounamu celeryd[30190]: No passwd entry for user 'celery'
  Nov 05 20:51:59 pounamu su[30206]: No passwd entry for user 'celery'
  Nov 05 20:51:59 pounamu su[30206]: FAILED su for celery by root
  Nov 05 20:51:59 pounamu su[30206]: - ??? root:celery
  Nov 05 20:51:59 pounamu systemd[1]: celeryd.service: control process exited, code=exited status=1
  </code></pre>
  
  <p>Any ideas where the bailing wire isn't working? Am I missing something major?</p>