daemonizing.rst 5.2 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203
  1. =============================
  2. Running celeryd as a daemon
  3. =============================
  4. Celery does not daemonize itself, please use one of the following
  5. daemonization tools.
  6. .. contents::
  7. :local:
  8. start-stop-daemon (Debian/Ubuntu/++)
  9. ====================================
  10. See the `contrib/debian/init.d/`_ directory in the celery distribution, this
  11. directory contains init scripts for celeryd and celerybeat.
  12. These scripts are configured in ``/etc/default/celeryd``.
  13. .. _`contrib/debian/init.d/`:
  14. http://github.com/ask/celery/tree/master/contrib/debian/
  15. Init script: celeryd
  16. --------------------
  17. :Usage: ``/etc/init.d/celeryd {start|stop|force-reload|restart|try-restart|status}``
  18. :Configuration file: /etc/default/celeryd
  19. To configure celeryd you probably need to at least tell it where to chdir
  20. when it starts (to find your celeryconfig).
  21. Example configuration
  22. ~~~~~~~~~~~~~~~~~~~~~
  23. This is an example configuration for a Python project.
  24. ``/etc/default/celeryd``::
  25. # Where to chdir at start.
  26. CELERYD_CHDIR="/opt/Myproject/"
  27. # Extra arguments to celeryd
  28. CELERYD_OPTS="--time-limit 300"
  29. # Name of the celery config module.#
  30. CELERY_CONFIG_MODULE="celeryconfig"
  31. Example Django configuration
  32. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  33. This is an example configuration for those using ``django-celery``::
  34. # Where the Django project is.
  35. CELERYD_CHDIR="/opt/Project/"
  36. # Path to celeryd
  37. CELERYD="/opt/Project/manage.py celeryd"
  38. # Name of the projects settings module.
  39. export DJANGO_SETTINGS_MODULE="settings"
  40. Available options
  41. ~~~~~~~~~~~~~~~~~~
  42. * CELERYD_OPTS
  43. Additional arguments to celeryd, see ``celeryd --help`` for a list.
  44. * CELERYD_CHDIR
  45. Path to chdir at start. Default is to stay in the current directory.
  46. * CELERYD_PID_FILE
  47. Full path to the pidfile. Default is /var/run/celeryd.pid.
  48. * CELERYD_LOG_FILE
  49. Full path to the celeryd logfile. Default is /var/log/celeryd.log
  50. * CELERYD_LOG_LEVEL
  51. Log level to use for celeryd. Default is INFO.
  52. * CELERYD
  53. Path to the celeryd program. Default is ``celeryd``.
  54. You can point this to an virtualenv, or even use manage.py for django.
  55. * CELERYD_USER
  56. User to run celeryd as. Default is current user.
  57. * CELERYD_GROUP
  58. Group to run celeryd as. Default is current user.
  59. Init script: celerybeat
  60. -----------------------
  61. :Usage: ``/etc/init.d/celerybeat {start|stop|force-reload|restart|try-restart|status}``
  62. :Configuration file: /etc/default/celerybeat or /etc/default/celeryd
  63. Example configuration
  64. ~~~~~~~~~~~~~~~~~~~~~
  65. This is an example configuration for a Python project:
  66. ``/etc/default/celeryd``::
  67. # Where to chdir at start.
  68. CELERYD_CHDIR="/opt/Myproject/"
  69. # Extra arguments to celeryd
  70. CELERYD_OPTS="--time-limit 300"
  71. # Extra arguments to celerybeat
  72. CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"
  73. # Name of the celery config module.#
  74. CELERY_CONFIG_MODULE="celeryconfig"
  75. Example Django configuration
  76. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  77. This is an example configuration for those using ``django-celery``::
  78. # Where the Django project is.
  79. CELERYD_CHDIR="/opt/Project/"
  80. # Name of the projects settings module.
  81. DJANGO_SETTINGS_MODULE="settings"
  82. # Path to celeryd
  83. CELERYD="/opt/Project/manage.py celeryd"
  84. # Path to celerybeat
  85. CELERYBEAT="/opt/Project/manage.py celerybeat"
  86. # Extra arguments to celerybeat
  87. CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"
  88. Available options
  89. ~~~~~~~~~~~~~~~~~
  90. * CELERYBEAT_OPTS
  91. Additional arguments to celerybeat, see ``celerybeat --help`` for a
  92. list.
  93. * CELERYBEAT_PIDFILE
  94. Full path to the pidfile. Default is /var/run/celeryd.pid.
  95. * CELERYBEAT_LOGFILE
  96. Full path to the celeryd logfile. Default is /var/log/celeryd.log
  97. * CELERYBEAT_LOG_LEVEL
  98. Log level to use for celeryd. Default is INFO.
  99. * CELERYBEAT
  100. Path to the celeryd program. Default is ``celeryd``.
  101. You can point this to an virtualenv, or even use manage.py for django.
  102. * CELERYBEAT_USER
  103. User to run celeryd as. Default is current user.
  104. * CELERYBEAT_GROUP
  105. Group to run celeryd as. Default is current user.
  106. Troubleshooting
  107. ---------------
  108. If you can't get the init scripts to work, you should try running
  109. them in *verbose mode*::
  110. $ sh -x /etc/init.d/celeryd start
  111. This can reveal hints as to why the service won't start.
  112. Also you will see the commands generated, so you can try to run the celeryd
  113. command manually to read the resulting error output.
  114. For example my ``sh -x`` output does this::
  115. ++ start-stop-daemon --start --chdir /opt/Opal/release/opal --quiet \
  116. --oknodo --background --make-pidfile --pidfile /var/run/celeryd.pid \
  117. --exec /opt/Opal/release/opal/manage.py celeryd -- --time-limit=300 \
  118. -f /var/log/celeryd.log -l INFO
  119. Run the celeryd command after ``--exec`` (without the ``--``) to show the
  120. actual resulting output::
  121. $ /opt/Opal/release/opal/manage.py celeryd --time-limit=300 \
  122. -f /var/log/celeryd.log -l INFO
  123. `supervisord`_
  124. ==============
  125. * `contrib/supervisord/`_
  126. .. _`contrib/supervisord/`:
  127. http://github.com/ask/celery/tree/master/contrib/supervisord/
  128. .. _`supervisord`: http://supervisord.org/
  129. launchd (OS X)
  130. ==============
  131. * `contrib/mac/`_
  132. .. _`contrib/mac/`:
  133. http://github.com/ask/celery/tree/master/contrib/mac/