how to detect failure and auto restart celery worker

只愿长相守 提交于 2021-02-05 08:35:59

问题


I use Celery and Celerybeat in my django powered website. the server OS is Ubuntu 16.04. by using celerybeat, a job is done by a celery worker every 10 minutes. sometimes the worker shuts down without any useful log messages or errors. So, I want to find a way in order to detect status (On/Off) of celery worker (not Beat), and if it's stopped, restart it automatically. how can I do that? thanks


回答1:


In production, you should run Celery, Beat, your APP server etc. as daemons [1] using Supervisor/Upstart/Systemd/.../.... There is a section about this in the Celery documentation. [2]

My favorite tool is Supervisord [3]. Here is Supervisord example configuration for Celery: https://github.com/celery/celery/tree/master/extra/supervisord and here https://github.com/illagrenan/ubuntu-supervisor-configuration is a tutorial about installing Supervisord on Ubuntu.

(...) Supervisord starts processes as its subprocesses, and can be configured to automatically restart them on a crash. (...)

Source: http://supervisord.org/introduction.html#introduction

  • [1] https://en.wikipedia.org/wiki/Daemon_(computing)
  • [2] http://docs.celeryproject.org/en/latest/userguide/daemonizing.html
  • [3] http://supervisord.org/


来源:https://stackoverflow.com/questions/54861717/how-to-detect-failure-and-auto-restart-celery-worker

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