daemonizing.rst 5.7 KB

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