My djcelery tasks run locally but not remotely?
<p>I have automated tasks working locally but not reomotely in my django app. I was watching a tutorial and the guy said to stop my worker. but before I did that I put my app in maintenance mode, that didn't work. then I ran</p>

<pre><code>heroku ps:restart
</code></pre>

<p>that didn't work, then I ran </p>

<pre><code>heroku ps:stop worker
</code></pre>

<p>which outputed </p>

<pre><code> Warning: The dynos in your dyno formation will be automatically restarted.
</code></pre>

<p>then I ran </p>

<pre><code>heroku ps:scale worker=1
</code></pre>

<p>and still nothing. I remind those who are reading this that it worked locally. What am I missing?</p>

<p>my procfile</p>

<pre><code>web: gunicorn gettingstarted.wsgi --log-file -
worker: celery worker -A blog -l info.
</code></pre>

<p>While researching I'm seeing mentions of adding beat to the procfile. 2 mentions in fact but this was not discussed in the tutorial I watched. only time celery beat was mentioned is when I added this to the settings.py file</p>

<pre><code>CELERYBEAT_SCHEDULER = 'djcelery.schedulers.DatabaseScheduler'
</code></pre>

<p>and just in case it makes a difference I'm using the djcelery gui to set periodic tasks not configuring the sceduler in the settings.py like I see in a majority of the examples. </p>

<p>If I run the task in my view and call it, it works. But it wont run if I set it up using djcelery</p>

<p>As you've read in the docs, using the <strong>-B</strong> option is not recommended for production use, you'd better run <code>celery-beat</code> as a different process.</p>

<p>So it's best practice to run it in the server like : </p>

<pre><code>celery beat -A messaging_router --loglevel=INFO
</code></pre>

<p>And if you're using <code>supervisor</code> to keep your processes running, you'd add something like the following to your configuration file.</p>

<pre><code>[program:api_beat]
command=/path/to/v_envs/v_env/bin/celery -A project beat --loglevel=info
autostart=true
autorestart=true
user=your_user (echo $USER)
directory=/path/to/project/root
stdout_logfile=/var/log/supervisor/beat.log
stderr_logfile=/var/log/supervisor/beat.log
redirect_stderr=true
environment=EVN_VAR1="whatever",
</code></pre>

<p>The reason for this is as the docs say</p>

<blockquote>
  <p>You can also start embed beat inside the worker by enabling workers -B option, this is convenient if you will never run more than one worker node, but itâs not commonly used and for that reason is not recommended for production use:</p>
</blockquote>

<p>Consider you having more than 1 worker, in maintenance, you need to always be vary of which one of the celery workers you've run with the <code>-B</code> and that definitely can be burden. </p>

python django heroku task crontab