title: Daemonizing celery
body: <p>Following instructions found <a href="http://docs.celeryproject.org/en/latest/tutorials/daemonizing.html">here</a>, I copied <a href="https://github.com/celery/celery/blob/3.1/extra/generic-init.d/celeryd">the script from github</a> into <em>/etc/init.d/celeryd</em>, then made it executable;</p>
  
  <pre><code>$ ll /etc/init.d/celeryd
  -rwxr-xr-x 1 root root 9481 Feb 19 11:27 /etc/init.d/celeryd*
  </code></pre>
  
  <p>I created config file <em>/etc/default/celeryd</em> as per instructions:</p>
  
  <pre><code># Names of nodes to start
  #   most will only start one node:
  #CELERYD_NODES="worker1"
  #   but you can also start multiple and configure settings
  #   for each in CELERYD_OPTS (see `celery multi --help` for examples).
  CELERYD_NODES="worker1 worker2 worker3"
  
  # Absolute or relative path to the 'celery' command:
  CELERY_BIN="/usr/local/bin/celery"
  #CELERY_BIN="/virtualenvs/def/bin/celery"
  
  # App instance to use
  # comment out this line if you don't use an app
  #CELERY_APP="proj"
  # or fully qualified:
  #CELERY_APP="proj.tasks:app"
  
  # Where to chdir at start.
  CELERYD_CHDIR="/path/to/folder/containing/tasks/"
  
  # Extra command-line arguments to the worker
  CELERYD_OPTS="--time-limit=3000 --concurrency=3 --config=celeryconfig"
  
  # %N will be replaced with the first part of the nodename.
  CELERYD_LOG_FILE="/var/log/celery/%N.log"
  CELERYD_PID_FILE="/var/run/celery/%N.pid"
  
  # Workers should run as an unprivileged user.
  #   You need to create this user manually (or you can choose
  #   a user/group combination that already exists, e.g. nobody).
  CELERYD_USER="celery"
  CELERYD_GROUP="celery"
  
  # If enabled pid and log directories will be created if missing,
  # and owned by the userid/group configured.
  CELERY_CREATE_DIRS=1
  </code></pre>
  
  <p><strong>Note</strong>: I added the <em>--config=celeryconfig</em> part in CELERYD_OPTS.</p>
  
  <p>I created a new user <em>celery</em> with</p>
  
  <pre><code>sudo useradd -N -M --system -s /bin/false celery
  </code></pre>
  
  <p>and then created group <em>celery</em> and added user to it:</p>
  
  <pre><code>$ id celery
  uid=999(celery) gid=1005(celery) groups=1005(celery)
  </code></pre>
  
  <p>I used chown celery:celery for folders:</p>
  
  <p><em>/var/run/celery/</em></p>
  
  <p><em>/var/log/celery/</em></p>
  
  <p>When I try to start the service, I get no indication of error:</p>
  
  <pre><code>$ sudo service celeryd start
  celery init v10.0.
  Using config script: /etc/default/celeryd
  </code></pre>
  
  <p>but status gives me "no pids were found":</p>
  
  <pre><code>$ sudo service celeryd status
  celery init v10.0.
  Using config script: /etc/default/celeryd
  celeryd is stopped: no pids were found
  </code></pre>
  
  <p>and indeed, ps -ef gives no results and no PID file or log files are created:</p>
  
  <pre><code>$ ll /var/run/celery
  total 0
  drwxr-sr-x  2 celery celery  40 Feb 19 14:13 ./
  drwxr-xr-x 16 root   root   620 Feb 19 12:35 ../
  
  $ ll /var/log/celery
  total 8
  drwxr-sr-x  2 celery celery 4096 Feb 19 14:13 ./
  drwxr-xr-x 13 root   root   4096 Feb 19 11:37 ../
  </code></pre>
  
  <p>Additional info:</p>
  
  <pre><code>$ pip freeze | grep celery
  celery==3.1.9
  </code></pre>
  
  <p>What am I missing? Where should I be looking for more clues as to why celeryd is not starting?</p>