Search code examples
pythondjangoherokucelerydjango-celery

Have to manually start worker on heroku?


In my Procfile I have the following:

worker: cd appname && celery -A appname worker -l info  --app=appname.celery_setup:app

However, when my app submits a task it never happens, but I think the celery worker is at least sort of working, because

heroku logs --app appname

every so often gives me one of these:

2016-07-22T07:53:21+00:00 app[heroku-redis]: source=REDIS sample#active-connections=14 sample#load-avg-1m=0.03 sample#load-avg-5m=0.09 sample#load-avg-15m=0.085 sample#read-iops=0 sample#write-iops=0 sample#memory-total=15664884.0kB sample#memory-free=13458244.0kB sample#memory-cached=187136kB sample#memory-redis=566800bytes sample#hit-rate=0.17778 sample#evicted-keys=0

Also, when I open up bash by running

heroku run bash --app appname

and then type in

cd appname && celery -A appname worker -l info  --app=appname.celery_setup:app

It immediately tells me the task has been received and then executes it. I would like to have this happen without me having to manually log in and execute the command - is that possible? Do I need a paid account on heroku to do that?


Solution

  • I figured it out. Turns out you also have to do

    heroku ps:scale worker=1 --app appname
    

    Or else you won't actually be running a worker.