Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to start celery in background of terminal in Django

I ma starting celery as

python manage.py celeryd

It is working but in foreground . Then to test commands i need to start another terminal and do stuff there.

is there any way to start that in background. I tried this

python manage.py celeryd &

But then again it comes at foreground

like image 304
Mirage Avatar asked Jul 12 '11 14:07

Mirage


3 Answers

You're looking for celeryd_detach, available since at least 2.4

python manage.py celeryd_detach
like image 96
Jack M. Avatar answered Nov 10 '22 12:11

Jack M.


You can use this to get celeryd to work in the background

$ nohup celeryd start &

The above command pushes the celery daemon to the background.

like image 4
Phalgun Avatar answered Nov 10 '22 13:11

Phalgun


You can try "Supervisor". Install "django-supervisor" in your project, create a supervisor.conf in the same folder than your manage.py.

then, you just run:

python manager.py supervisor --daemonize

My supervisor.conf:

[program:celeryd]
command={{ PYTHON }} {{ PROJECT_DIR }}/manage.py celeryd -l info
autostart=true
autorestart=true
stopwaitsecs = 600

[program:autoreload]
exclude=true
[program:runserver]
exclude=true
[program:celerybeat]
exclude=true
like image 4
cmaluenda Avatar answered Nov 10 '22 13:11

cmaluenda