configuration.rst 7.0 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268
  1. ============================
  2. Configuration and defaults
  3. ============================
  4. This document describes the configuration options available.
  5. If you're using celery in a Django project these settings should be defined
  6. in your projects ``settings.py`` file.
  7. In a regular Python environment using the default loader you must create
  8. the ``celeryconfig.py`` module and make sure it is available on the
  9. Python path.
  10. Concurrency settings
  11. ====================
  12. * CELERYD_CONCURRENCY
  13. The number of concurrent worker processes, executing tasks simultaneously.
  14. Defaults to the number of CPUs in the system.
  15. Task result backend settings
  16. ============================
  17. * CELERY_BACKEND
  18. The backend used to store task results (tombstones).
  19. Can be one of the following:
  20. * database (default)
  21. Use a relational database supported by the Django ORM.
  22. * cache
  23. Use memcached to store the results.
  24. * mongodb
  25. Use MongoDB to store the results.
  26. * tyrant
  27. Use Tokyo Tyrant to store the results.
  28. * CELERY_PERIODIC_STATUS_BACKEND
  29. The backend used to store the status of periodic tasks.
  30. Can be one of the following:
  31. * database (default)
  32. Use a relational database supported by the Django ORM.
  33. * mongodb
  34. Use MongoDB.
  35. Database backend settings
  36. =========================
  37. This applies to both the result store backend and the periodic status
  38. backend.
  39. Please see the Django ORM database settings documentation:
  40. http://docs.djangoproject.com/en/dev/ref/settings/#database-engine
  41. If you use this backend make sure to initialize the database tables
  42. after configuration. When using celery with a Django project this
  43. means executing::
  44. $ python manage.py syncdb
  45. When using celery in a regular Python environment you have to execute::
  46. $ celeryinit
  47. Example configuration
  48. ---------------------
  49. .. code-block:: python
  50. DATABASE_ENGINE="mysql"
  51. DATABASE_USER="myusername"
  52. DATABASE_PASSWORD="mypassword"
  53. DATABASE_NAME="mydatabase"
  54. DATABASE_HOST="localhost"
  55. Cache backend settings
  56. ======================
  57. Please see the documentation for the Django cache framework settings:
  58. http://docs.djangoproject.com/en/dev/topics/cache/#memcached
  59. Example configuration
  60. ---------------------
  61. Using a single memcached server:
  62. .. code-block:: python
  63. CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
  64. Using multiple memcached servers:
  65. .. code-block:: python
  66. CACHE_BACKEND = 'memcached://172.19.26.240:11211;172.19.26.242:11211/'
  67. Tokyo Tyrant backend settings
  68. =============================
  69. **NOTE** The Tokyo Tyrant backend requires the :mod:`pytyrant` library:
  70. http://pypi.python.org/pypi/pytyrant/
  71. This backend requires the following configuration variables to be set:
  72. * TT_HOST
  73. Hostname of the Tokyo Tyrant server.
  74. * TT_PORT
  75. The port the Tokyo Tyrant server is listening to.
  76. Example configuration
  77. ---------------------
  78. .. code-block:: python
  79. TT_HOST = "localhost"
  80. TT_PORT = 1978
  81. MongoDB backend settings
  82. ========================
  83. * CELERY_MONGODB_BACKEND_SETTINGS
  84. This is a dict supporting the following keys
  85. * host
  86. Hostname of the MongoDB server.
  87. * port
  88. The port the MongoDB server is listening to.
  89. * user
  90. Username to authenticate to the MongoDB server as.
  91. * password
  92. * database
  93. The database name to connect to.
  94. * taskmeta_collection
  95. FIXME
  96. * periodictaskmeta_collection
  97. FIXME
  98. Broker settings
  99. ===============
  100. * CELERY_AMQP_EXCHANGE
  101. Name of the AMQP exchange.
  102. * CELERY_AMQP_EXCHANGE_TYPE
  103. The type of exchange. If the exchange type is ``direct``, all messages
  104. receives all tasks. However, if the exchange type is ``topic``, you can
  105. route e.g. some tasks to one server, and others to the rest.
  106. See `Exchange types and the effect of bindings`_.
  107. .. _`Exchange types and the effect of bindings`:
  108. http://bit.ly/wpamqpexchanges
  109. * CELERY_AMQP_PUBLISHER_ROUTING_KEY
  110. The default AMQP routing key used when publishing tasks.
  111. * CELERY_AMQP_CONSUMER_ROUTING_KEY
  112. The AMQP routing key used when consuming tasks.
  113. * CELERY_AMQP_CONSUMER_QUEUE
  114. The name of the AMQP queue.
  115. * CELERY_AMQP_CONSUMER_QUEUES
  116. Dictionary defining multiple AMQP queues.
  117. * CELERY_AMQP_CONNECTION_TIMEOUT
  118. The timeout in seconds before we give up establishing a connection
  119. to the AMQP server. Default is 4 seconds.
  120. * CELERY_AMQP_CONNECTION_RETRY
  121. Automatically try to re-establish the connection to the AMQP broker if
  122. it's lost.
  123. The time between retries is increased for each retry, and is
  124. not exhausted before ``CELERY_AMQP_CONNECTION_MAX_RETRIES`` is exceeded.
  125. This behaviour is on by default.
  126. * CELERY_AMQP_CONNECTION_MAX_RETRIES
  127. Maximum number of retries before we give up re-establishing a connection
  128. to the AMQP broker.
  129. If this is set to ``0`` or ``None``, we will retry forever.
  130. Default is 100 retries.
  131. Task execution settings
  132. =======================
  133. * SEND_CELERY_TASK_ERROR_EMAILS
  134. If set to ``True``, errors in tasks will be sent to admins by e-mail.
  135. If unset, it will send the e-mails if ``settings.DEBUG`` is False.
  136. * CELERY_ALWAYS_EAGER
  137. If this is ``True``, all tasks will be executed locally by blocking
  138. until it is finished. ``apply_async`` and ``delay_task`` will return
  139. a :class:`celery.result.EagerResult` which emulates the behaviour of
  140. an :class:`celery.result.AsyncResult`.
  141. Tasks will never be sent to the queue, but executed locally
  142. instead.
  143. * CELERY_TASK_RESULT_EXPIRES
  144. Time (in seconds, or a :class:`datetime.timedelta` object) for when after
  145. stored task tombstones are deleted.
  146. **NOTE**: For the moment this only works for the database and MongoDB
  147. backends.
  148. * CELERY_TASK_SERIALIZER
  149. A string identifying the default serialization
  150. method to use. Can be ``pickle`` (default),
  151. ``json``, ``yaml``, or any custom serialization methods that have
  152. been registered with :mod:`carrot.serialization.registry`.
  153. Default is ``pickle``.
  154. Logging settings
  155. ================
  156. * CELERYD_LOG_FILE
  157. The default filename the worker daemon logs messages to, can be
  158. overridden using the `--logfile`` option to ``celeryd``.
  159. The default is to log using ``stderr`` if running in the foreground,
  160. when running in the background, detached as a daemon, the default
  161. logfile is ``celeryd.log``.
  162. * CELERYD_DAEMON_LOG_LEVEL
  163. Worker log level, can be any of ``DEBUG``, ``INFO``, ``WARNING``,
  164. ``ERROR``, ``CRITICAL``, or ``FATAL``.
  165. See the :mod:`logging` module for more information.
  166. * CELERYD_DAEMON_LOG_FORMAT
  167. The format to use for log messages. Can be overridden using
  168. the ``--loglevel`` option to ``celeryd``.
  169. Default is ``[%(asctime)s: %(levelname)s/%(processName)s] %(message)s``
  170. See the Python :mod:`logging` module for more information about log
  171. formats.
  172. Process settings
  173. ================
  174. * CELERYD_PID_FILE
  175. Full path to the daemon pid file. Default is ``celeryd.pid``.
  176. Can be overridden using the ``--pidfile`` option to ``celeryd``.