title: Automatically starting Celery from within Django app
body: <p>I am getting a Django 1.6 set up started on a Linux (Debian Whiskey) server on Google Compute Engine. I've got Celery 3.1 running in the background to help with some processes. When I start a new instance (using a snapshot I've created), I always need to start Celery. I am looking for a way to start Celery automatically on server-load. This is particularly helpful if the server decides to restart, as they seem to do now and then. To achieve this, I've edited the <code>rc.local</code> file:</p>
  
  <pre><code>$ sudo nano /etc/rc.local
  </code></pre>
  
  <p>It used to contain the following:</p>
  
  <pre><code>exit 0
  [ -x /sbin/initctl ] &amp;&amp; initctl emit --no-wait google-rc-local-has-run || true
  </code></pre>
  
  <p>I've edited the file such that it now reads:</p>
  
  <pre><code>cd /home/user/gce_app celery -A myapp.tasks --concurrency=1 --loglevel=info worker &gt; output.log 2&gt; errors.log &amp;
  exit 0
  [ -x /sbin/initctl ] &amp;&amp; initctl emit --no-wait google-rc-local-has-run || true
  </code></pre>
  
  <p>The directory:</p>
  
  <pre><code>/home/user/gce_app
  </code></pre>
  
  <p>is where my Django project resides and the directory I need to be in to start Celery. However, after restarting the instance, when I type in:</p>
  
  <pre><code>$ celery status
  Error: No nodes replied within time constraint.
  </code></pre>
  
  <p>Opening the <code>errors.log</code> file, I see:</p>
  
  <pre><code>/etc/rc.local: 14: /etc/rc.local: celery: not found
  </code></pre>
  
  <p>Surely the <code>cd</code> at the start of that code string should address this? Is there a way (within the Django project itself) to start the Celery instance when the project is started to make the code more platform-independent and immune to inevitable OS updates?</p>