How to start celery in background of terminal in Django

大兔子大兔子 提交于 2019-12-10 15:31:05

问题


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


回答1:


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

python manage.py celeryd_detach



回答2:


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.




回答3:


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


来源:https://stackoverflow.com/questions/6665893/how-to-start-celery-in-background-of-terminal-in-django

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!