This is a repo for running celery in daemon mode in production. Simple celery app with python code and celeryd conf
Switch branches/tags
Nothing to show
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.


####Running celery in Daemon##########


sudo apt-get install python-celery celeryd

  • Prerequiste:
    • rabbitmq (see here)

    • celery (pip install celery)

Sample celery app

save this as

from __future__ import absolute_import
from celery import Celery
import sys
import time

celery_url = "amqp://%s:%s@%s//" % ("guest", "guest", "")

celery_app = Celery("testapp", broker=celery_url,

def add(x,y):
    print "hi from task add", x, y
    return x+y

def main(x,y):
        This is main function gets called initially while running 
    print "Let's add %s and %s" % (x, y)
    res = add.apply_async(args=[x, y])
    if res.ready():
        print "Result from task %s" % res.result

if __name__ == '__main__':
    if len(sys.argv) < 3:
        print "Usage: python 1 2"
    x = int(sys.argv[1])
    y = int(sys.argv[2])

Configure celeryd in /etc/default/celeryd

If you have installed celeryd it created daemon script in /etc/default/celeryd.

change/add these lines in /etc/default/celeryd

ENABLED="true" # enable daemon mode
# change above line to the directory which contains our
CELERYD_OPTS="--app=testapp --loglevel=info --time-limit=300 --concurrency=8"

Now restart celeryd to reflect config changes

sudo service celeryd restart

which results like this

celery multi v3.1.6 (Cipater)
> Starting nodes...
    > w1@bala: OK

you can check the logs in /var/log/celery/w1.log

Run python file by python 2 3

which gives us

Let's add 2 and 3
Result from task 5