daemonizing.rst 5.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229
  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 :file:`/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 change
  23. directory to 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. :file:`/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 change directory to at start. Default is to stay in the current
  52. directory.
  53. * CELERYD_PID_FILE
  54. Full path to the PID file. Default is /var/run/celeryd.pid.
  55. * CELERYD_LOG_FILE
  56. Full path to the celeryd log file. Default is /var/log/celeryd.log
  57. * CELERYD_LOG_LEVEL
  58. Log level to use for celeryd. Default is INFO.
  59. * CELERYD
  60. Path to the celeryd program. Default is `celeryd`.
  61. You can point this to an virtualenv, or even use manage.py for django.
  62. * CELERYD_USER
  63. User to run celeryd as. Default is current user.
  64. * CELERYD_GROUP
  65. Group to run celeryd as. Default is current user.
  66. .. _debian-initd-celerybeat:
  67. Init script: celerybeat
  68. -----------------------
  69. :Usage: `/etc/init.d/celerybeat {start|stop|force-reload|restart|try-restart|status}`
  70. :Configuration file: /etc/default/celerybeat or /etc/default/celeryd
  71. .. _debian-initd-celerybeat-example:
  72. Example configuration
  73. ~~~~~~~~~~~~~~~~~~~~~
  74. This is an example configuration for a Python project:
  75. `/etc/default/celeryd`::
  76. # Where to chdir at start.
  77. CELERYD_CHDIR="/opt/Myproject/"
  78. # Extra arguments to celeryd
  79. CELERYD_OPTS="--time-limit 300"
  80. # Extra arguments to celerybeat
  81. CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"
  82. # Name of the celery config module.#
  83. CELERY_CONFIG_MODULE="celeryconfig"
  84. .. _debian-initd-celerybeat-django-example:
  85. Example Django configuration
  86. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  87. This is an example configuration for those using `django-celery`::
  88. # Where the Django project is.
  89. CELERYD_CHDIR="/opt/Project/"
  90. # Name of the projects settings module.
  91. DJANGO_SETTINGS_MODULE="settings"
  92. # Path to celeryd
  93. CELERYD="/opt/Project/manage.py celeryd"
  94. # Path to celerybeat
  95. CELERYBEAT="/opt/Project/manage.py celerybeat"
  96. # Extra arguments to celerybeat
  97. CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"
  98. .. _debian-initd-celerybeat-options:
  99. Available options
  100. ~~~~~~~~~~~~~~~~~
  101. * CELERYBEAT_OPTS
  102. Additional arguments to celerybeat, see `celerybeat --help` for a
  103. list.
  104. * CELERYBEAT_PIDFILE
  105. Full path to the PID file. Default is /var/run/celeryd.pid.
  106. * CELERYBEAT_LOGFILE
  107. Full path to the celeryd log file. Default is /var/log/celeryd.log
  108. * CELERYBEAT_LOG_LEVEL
  109. Log level to use for celeryd. Default is INFO.
  110. * CELERYBEAT
  111. Path to the celeryd program. Default is `celeryd`.
  112. You can point this to an virtualenv, or even use manage.py for django.
  113. * CELERYBEAT_USER
  114. User to run celeryd as. Default is current user.
  115. * CELERYBEAT_GROUP
  116. Group to run celeryd as. Default is current user.
  117. .. _debian-initd-troubleshooting:
  118. Troubleshooting
  119. ---------------
  120. If you can't get the init scripts to work, you should try running
  121. them in *verbose mode*::
  122. $ sh -x /etc/init.d/celeryd start
  123. This can reveal hints as to why the service won't start.
  124. Also you will see the commands generated, so you can try to run the celeryd
  125. command manually to read the resulting error output.
  126. For example my `sh -x` output does this::
  127. ++ start-stop-daemon --start --chdir /opt/Opal/release/opal --quiet \
  128. --oknodo --background --make-pidfile --pidfile /var/run/celeryd.pid \
  129. --exec /opt/Opal/release/opal/manage.py celeryd -- --time-limit=300 \
  130. -f /var/log/celeryd.log -l INFO
  131. Run the celeryd command after `--exec` (without the `--`) to show the
  132. actual resulting output::
  133. $ /opt/Opal/release/opal/manage.py celeryd --time-limit=300 \
  134. -f /var/log/celeryd.log -l INFO
  135. .. _daemon-supervisord:
  136. `supervisord`_
  137. ==============
  138. * `contrib/supervisord/`_
  139. .. _`contrib/supervisord/`:
  140. http://github.com/ask/celery/tree/master/contrib/supervisord/
  141. .. _`supervisord`: http://supervisord.org/
  142. .. _daemon-launchd:
  143. launchd (OS X)
  144. ==============
  145. * `contrib/mac/`_
  146. .. _`contrib/mac/`:
  147. http://github.com/ask/celery/tree/master/contrib/mac/