configuration.rst 23 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033
  1. .. _configuration:
  2. ============================
  3. Configuration and defaults
  4. ============================
  5. This document describes the configuration options available.
  6. If you're using the default loader, you must create the :file:`celeryconfig.py`
  7. module and make sure it is available on the Python path.
  8. .. contents::
  9. :local:
  10. :depth: 2
  11. .. _conf-example:
  12. Example configuration file
  13. ==========================
  14. This is an example configuration file to get you started.
  15. It should contain all you need to run a basic Celery set-up.
  16. .. code-block:: python
  17. # List of modules to import when celery starts.
  18. CELERY_IMPORTS = ("myapp.tasks", )
  19. ## Result store settings.
  20. CELERY_RESULT_BACKEND = "database"
  21. CELERY_RESULT_DBURI = "sqlite:///mydatabase.db"
  22. ## Broker settings.
  23. BROKER_HOST = "localhost"
  24. BROKER_PORT = 5672
  25. BROKER_VHOST = "/"
  26. BROKER_USER = "guest"
  27. BROKER_PASSWORD = "guest"
  28. ## Worker settings
  29. ## If you're doing mostly I/O you can have more processes,
  30. ## but if mostly spending CPU, try to keep it close to the
  31. ## number of CPUs on your machine. If not set, the number of CPUs/cores
  32. ## available will be used.
  33. CELERYD_CONCURRENCY = 10
  34. # CELERYD_LOG_FILE = "celeryd.log"
  35. # CELERYD_LOG_LEVEL = "INFO"
  36. Configuration Directives
  37. ========================
  38. .. _conf-concurrency:
  39. Concurrency settings
  40. --------------------
  41. .. _CELERYD_CONCURRENCY:
  42. CELERYD_CONCURRENCY
  43. ~~~~~~~~~~~~~~~~~~~
  44. The number of concurrent worker processes, executing tasks simultaneously.
  45. Defaults to the number of CPUs/cores available.
  46. .. _CELERYD_PREFETCH_MULTIPLIER:
  47. CELERYD_PREFETCH_MULTIPLIER
  48. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  49. How many messages to prefetch at a time multiplied by the number of
  50. concurrent processes. The default is 4 (four messages for each
  51. process). The default setting is usually a good choice, however -- if you
  52. have very long running tasks waiting in the queue and you have to start the
  53. workers, note that the first worker to start will receive four times the
  54. number of messages initially. Thus the tasks may not be fairly distributed
  55. to the workers.
  56. .. _conf-result-backend:
  57. Task result backend settings
  58. ----------------------------
  59. .. _CELERY_RESULT_BACKEND:
  60. CELERY_RESULT_BACKEND
  61. ~~~~~~~~~~~~~~~~~~~~~
  62. The backend used to store task results (tombstones).
  63. Can be one of the following:
  64. * database (default)
  65. Use a relational database supported by `SQLAlchemy`_.
  66. See :ref:`conf-database-result-backend`.
  67. * cache
  68. Use `memcached`_ to store the results.
  69. See :ref:`conf-cache-result-backend`.
  70. * mongodb
  71. Use `MongoDB`_ to store the results.
  72. See :ref:`conf-mongodb-result-backend`.
  73. * redis
  74. Use `Redis`_ to store the results.
  75. See :ref:`conf-redis-result-backend`.
  76. * tyrant
  77. Use `Tokyo Tyrant`_ to store the results.
  78. See :ref:`conf-tyrant-result-backend`.
  79. * amqp
  80. Send results back as AMQP messages
  81. See :ref:`conf-amqp-result-backend`.
  82. .. warning:
  83. While the AMQP result backend is very efficient, you must make sure
  84. you only receive the same result once. See :doc:`userguide/executing`).
  85. .. _`SQLAlchemy`: http://sqlalchemy.org
  86. .. _`memcached`: http://memcached.org
  87. .. _`MongoDB`: http://mongodb.org
  88. .. _`Redis`: http://code.google.com/p/redis/
  89. .. _`Tokyo Tyrant`: http://1978th.net/tokyotyrant/
  90. .. _conf-database-result-backend:
  91. Database backend settings
  92. -------------------------
  93. .. _CELERY_RESULT_DBURI:
  94. CELERY_RESULT_DBURI
  95. ~~~~~~~~~~~~~~~~~~~
  96. Please see `Supported Databases`_ for a table of supported databases.
  97. To use this backend you need to configure it with an
  98. `Connection String`_, some examples include:
  99. .. code-block:: python
  100. # sqlite (filename)
  101. CELERY_RESULT_DBURI = "sqlite:///celerydb.sqlite"
  102. # mysql
  103. CELERY_RESULT_DBURI = "mysql://scott:tiger@localhost/foo"
  104. # postgresql
  105. CELERY_RESULT_DBURI = "postgresql://scott:tiger@localhost/mydatabase"
  106. # oracle
  107. CELERY_RESULT_DBURI = "oracle://scott:tiger@127.0.0.1:1521/sidname"
  108. See `Connection String`_ for more information about connection
  109. strings.
  110. .. _CELERY_RESULT_ENGINE_OPTIONS:
  111. CELERY_RESULT_ENGINE_OPTIONS
  112. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  113. To specify additional SQLAlchemy database engine options you can use
  114. the :setting:`CELERY_RESULT_ENGINE_OPTIONS` setting::
  115. # echo enables verbose logging from SQLAlchemy.
  116. CELERY_RESULT_ENGINE_OPTIONS = {"echo": True}
  117. .. _`Supported Databases`:
  118. http://www.sqlalchemy.org/docs/dbengine.html#supported-databases
  119. .. _`Connection String`:
  120. http://www.sqlalchemy.org/docs/dbengine.html#create-engine-url-arguments
  121. Example configuration
  122. ~~~~~~~~~~~~~~~~~~~~~
  123. .. code-block:: python
  124. CELERY_RESULT_BACKEND = "database"
  125. CELERY_RESULT_DBURI = "mysql://user:password@host/dbname"
  126. .. _conf-amqp-result-backend:
  127. AMQP backend settings
  128. ---------------------
  129. .. _CELERY_AMQP_TASK_RESULT_EXPIRES:
  130. CELERY_AMQP_TASK_RESULT_EXPIRES
  131. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  132. The time in seconds of which the task result queues should expire.
  133. .. note::
  134. AMQP result expiration requires RabbitMQ versions 2.1.0 and higher.
  135. .. _CELERY_RESULT_EXCHANGE:
  136. CELERY_RESULT_EXCHANGE
  137. ~~~~~~~~~~~~~~~~~~~~~~
  138. Name of the exchange to publish results in. Default is ``"celeryresults"``.
  139. .. _CELERY_RESULT_EXCHANGE_TYPE:
  140. CELERY_RESULT_EXCHANGE_TYPE
  141. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  142. The exchange type of the result exchange. Default is to use a ``direct``
  143. exchange.
  144. .. _CELERY_RESULT_SERIALIZER:
  145. CELERY_RESULT_SERIALIZER
  146. ~~~~~~~~~~~~~~~~~~~~~~~~
  147. Result message serialization format. Default is ``"pickle"``.
  148. .. _CELERY_RESULT_PERSISTENT:
  149. CELERY_RESULT_PERSISTENT
  150. ~~~~~~~~~~~~~~~~~~~~~~~~
  151. If set to :const:`True`, result messages will be persistent. This means the
  152. messages will not be lost after a broker restart. The default is for the
  153. results to be transient.
  154. Example configuration
  155. ~~~~~~~~~~~~~~~~~~~~~
  156. .. code-block:: python
  157. CELERY_RESULT_BACKEND = "amqp"
  158. CELERY_AMQP_TASK_RESULT_EXPIRES = 18000 # 5 hours.
  159. .. _conf-cache-result-backend:
  160. Cache backend settings
  161. ----------------------
  162. .. note::
  163. The cache backend supports the `pylibmc`_ and `python-memcached`
  164. libraries. The latter is used only if `pylibmc`_ is not installed.
  165. .. _CELERY_CACHE_BACKEND:
  166. CELERY_CACHE_BACKEND
  167. ~~~~~~~~~~~~~~~~~~~~
  168. Using a single memcached server:
  169. .. code-block:: python
  170. CELERY_CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
  171. Using multiple memcached servers:
  172. .. code-block:: python
  173. CELERY_RESULT_BACKEND = "cache"
  174. CELERY_CACHE_BACKEND = 'memcached://172.19.26.240:11211;172.19.26.242:11211/'
  175. .. _CELERY_CACHE_BACKEND_OPTIONS:
  176. CELERY_CACHE_BACKEND_OPTIONS
  177. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  178. You can set pylibmc options using the :setting:`CELERY_CACHE_BACKEND_OPTIONS`
  179. setting:
  180. .. code-block:: python
  181. CELERY_CACHE_BACKEND_OPTIONS = {"binary": True,
  182. "behaviors": {"tcp_nodelay": True}}
  183. .. _`pylibmc`: http://sendapatch.se/projects/pylibmc/
  184. .. _conf-tyrant-result-backend:
  185. Tokyo Tyrant backend settings
  186. -----------------------------
  187. .. note::
  188. The Tokyo Tyrant backend requires the :mod:`pytyrant` library:
  189. http://pypi.python.org/pypi/pytyrant/
  190. This backend requires the following configuration directives to be set:
  191. .. _TT_HOST:
  192. TT_HOST
  193. ~~~~~~~
  194. Hostname of the Tokyo Tyrant server.
  195. .. _TT_PORT:
  196. TT_PORT
  197. ~~~~~~~
  198. The port the Tokyo Tyrant server is listening to.
  199. Example configuration
  200. ~~~~~~~~~~~~~~~~~~~~~
  201. .. code-block:: python
  202. CELERY_RESULT_BACKEND = "tyrant"
  203. TT_HOST = "localhost"
  204. TT_PORT = 1978
  205. .. _conf-redis-result-backend:
  206. Redis backend settings
  207. ----------------------
  208. .. note::
  209. The Redis backend requires the :mod:`redis` library:
  210. http://pypi.python.org/pypi/redis/0.5.5
  211. To install the redis package use ``pip`` or ``easy_install``::
  212. $ pip install redis
  213. This backend requires the following configuration directives to be set.
  214. .. _REDIS_HOST:
  215. REDIS_HOST
  216. ~~~~~~~~~~
  217. Hostname of the Redis database server. e.g. ``"localhost"``.
  218. .. _REDIS_PORT:
  219. REDIS_PORT
  220. ~~~~~~~~~~
  221. Port to the Redis database server. e.g. ``6379``.
  222. .. _REDIS_DB:
  223. REDIS_DB
  224. ~~~~~~~~
  225. Database number to use. Default is 0
  226. .. _REDIS_PASSWORD:
  227. REDIS_PASSWORD
  228. ~~~~~~~~~~~~~~
  229. Password used to connect to the database.
  230. Example configuration
  231. ~~~~~~~~~~~~~~~~~~~~~
  232. .. code-block:: python
  233. CELERY_RESULT_BACKEND = "redis"
  234. REDIS_HOST = "localhost"
  235. REDIS_PORT = 6379
  236. REDIS_DB = "celery_results"
  237. REDIS_CONNECT_RETRY=True
  238. .. _conf-mongodb-result-backend:
  239. MongoDB backend settings
  240. ------------------------
  241. .. note::
  242. The MongoDB backend requires the :mod:`pymongo` library:
  243. http://github.com/mongodb/mongo-python-driver/tree/master
  244. .. _CELERY_MONGODB_BACKEND_SETTINGS:
  245. CELERY_MONGODB_BACKEND_SETTINGS
  246. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  247. This is a dict supporting the following keys:
  248. * host
  249. Hostname of the MongoDB server. Defaults to "localhost".
  250. * port
  251. The port the MongoDB server is listening to. Defaults to 27017.
  252. * user
  253. User name to authenticate to the MongoDB server as (optional).
  254. * password
  255. Password to authenticate to the MongoDB server (optional).
  256. * database
  257. The database name to connect to. Defaults to "celery".
  258. * taskmeta_collection
  259. The collection name to store task meta data.
  260. Defaults to "celery_taskmeta".
  261. .. _example-mongodb-result-config:
  262. Example configuration
  263. ~~~~~~~~~~~~~~~~~~~~~
  264. .. code-block:: python
  265. CELERY_RESULT_BACKEND = "mongodb"
  266. CELERY_MONGODB_BACKEND_SETTINGS = {
  267. "host": "192.168.1.100",
  268. "port": 30000,
  269. "database": "mydb",
  270. "taskmeta_collection": "my_taskmeta_collection",
  271. }
  272. .. _conf-messaging:
  273. Message Routing
  274. ---------------
  275. .. _conf-messaging-routing:
  276. .. _CELERY_QUEUES:
  277. CELERY_QUEUES
  278. ~~~~~~~~~~~~~
  279. The mapping of queues the worker consumes from. This is a dictionary
  280. of queue name/options. See :ref:`guide-routing` for more information.
  281. The default is a queue/exchange/binding key of ``"celery"``, with
  282. exchange type ``direct``.
  283. You don't have to care about this unless you want custom routing facilities.
  284. .. _CELERY_DEFAULT_QUEUE:
  285. CELERY_DEFAULT_QUEUE
  286. ~~~~~~~~~~~~~~~~~~~~
  287. The queue used by default, if no custom queue is specified. This queue must
  288. be listed in :setting:`CELERY_QUEUES`. The default is: ``celery``.
  289. .. _CELERY_DEFAULT_EXCHANGE:
  290. CELERY_DEFAULT_EXCHANGE
  291. ~~~~~~~~~~~~~~~~~~~~~~~
  292. Name of the default exchange to use when no custom exchange is
  293. specified. The default is: ``celery``.
  294. .. _CELERY_DEFAULT_EXCHANGE_TYPE:
  295. CELERY_DEFAULT_EXCHANGE_TYPE
  296. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  297. Default exchange type used when no custom exchange is specified.
  298. The default is: ``direct``.
  299. .. _CELERY_DEFAULT_ROUTING_KEY:
  300. CELERY_DEFAULT_ROUTING_KEY
  301. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  302. The default routing key used when sending tasks.
  303. The default is: ``celery``.
  304. .. _CELERY_DEFAULT_DELIVERY_MODE:
  305. CELERY_DEFAULT_DELIVERY_MODE
  306. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  307. Can be ``transient`` or ``persistent``. The default is to send
  308. persistent messages.
  309. .. _conf-broker-connection:
  310. Broker Settings
  311. ---------------
  312. .. _CELERY_BROKER_CONNECTION_TIMEOUT:
  313. CELERY_BROKER_CONNECTION_TIMEOUT
  314. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  315. The default timeout in seconds before we give up establishing a connection
  316. to the AMQP server. Default is 4 seconds.
  317. .. _CELERY_BROKER_CONNECTION_RETRY:
  318. CELERY_BROKER_CONNECTION_RETRY
  319. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  320. Automatically try to re-establish the connection to the AMQP broker if lost.
  321. The time between retries is increased for each retry, and is
  322. not exhausted before :setting:`CELERY_BROKER_CONNECTION_MAX_RETRIES` is
  323. exceeded.
  324. This behavior is on by default.
  325. .. _CELERY_BROKER_CONNECTION_MAX_RETRIES:
  326. CELERY_BROKER_CONNECTION_MAX_RETRIES
  327. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  328. Maximum number of retries before we give up re-establishing a connection
  329. to the AMQP broker.
  330. If this is set to :const:`0` or :const:`None`, we will retry forever.
  331. Default is 100 retries.
  332. .. _conf-task-execution:
  333. Task execution settings
  334. -----------------------
  335. .. _CELERY_ALWAYS_EAGER:
  336. CELERY_ALWAYS_EAGER
  337. ~~~~~~~~~~~~~~~~~~~
  338. If this is :const:`True`, all tasks will be executed locally by blocking
  339. until it is finished. ``apply_async`` and ``Task.delay`` will return
  340. a :class:`~celery.result.EagerResult` which emulates the behavior of
  341. :class:`~celery.result.AsyncResult`, except the result has already
  342. been evaluated.
  343. Tasks will never be sent to the queue, but executed locally
  344. instead.
  345. .. _CELERY_EAGER_PROPAGATES_EXCEPTIONS:
  346. CELERY_EAGER_PROPAGATES_EXCEPTIONS
  347. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  348. If this is :const:`True`, eagerly executed tasks (using ``.apply``, or with
  349. :setting:`CELERY_ALWAYS_EAGER` on), will raise exceptions.
  350. It's the same as always running ``apply`` with ``throw=True``.
  351. .. _CELERY_IGNORE_RESULT:
  352. CELERY_IGNORE_RESULT
  353. ~~~~~~~~~~~~~~~~~~~~
  354. Whether to store the task return values or not (tombstones).
  355. If you still want to store errors, just not successful return values,
  356. you can set :setting:`CELERY_STORE_ERRORS_EVEN_IF_IGNORED`.
  357. .. _CELERY_TASK_RESULT_EXPIRES:
  358. CELERY_TASK_RESULT_EXPIRES
  359. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  360. Time (in seconds, or a :class:`~datetime.timedelta` object) for when after
  361. stored task tombstones will be deleted.
  362. A built-in periodic task will delete the results after this time
  363. (:class:`celery.task.builtins.backend_cleanup`).
  364. .. note::
  365. For the moment this only works with the database, cache, redis and MongoDB
  366. backends. For the AMQP backend see
  367. :setting:`CELERY_AMQP_TASK_RESULT_EXPIRES`.
  368. When using the database or MongoDB backends, ``celerybeat`` must be
  369. running for the results to be expired.
  370. .. _CELERY_MAX_CACHED_RESULTS:
  371. CELERY_MAX_CACHED_RESULTS
  372. ~~~~~~~~~~~~~~~~~~~~~~~~~
  373. Total number of results to store before results are evicted from the
  374. result cache. The default is 5000.
  375. .. _CELERY_TRACK_STARTED:
  376. CELERY_TRACK_STARTED
  377. ~~~~~~~~~~~~~~~~~~~~
  378. If :const:`True` the task will report its status as "started" when the
  379. task is executed by a worker. The default value is :const:`False` as
  380. the normal behaviour is to not report that level of granularity. Tasks
  381. are either pending, finished, or waiting to be retried. Having a "started"
  382. state can be useful for when there are long running tasks and there is a
  383. need to report which task is currently running.
  384. .. _CELERY_TASK_SERIALIZER:
  385. CELERY_TASK_SERIALIZER
  386. ~~~~~~~~~~~~~~~~~~~~~~
  387. A string identifying the default serialization method to use. Can be
  388. ``pickle`` (default), ``json``, ``yaml``, or any custom serialization
  389. methods that have been registered with :mod:`carrot.serialization.registry`.
  390. .. _CELERY_DEFAULT_RATE_LIMIT:
  391. CELERY_DEFAULT_RATE_LIMIT
  392. ~~~~~~~~~~~~~~~~~~~~~~~~~
  393. The global default rate limit for tasks.
  394. This value is used for tasks that does not have a custom rate limit
  395. The default is no rate limit.
  396. .. _CELERY_DISABLE_RATE_LIMITS:
  397. CELERY_DISABLE_RATE_LIMITS
  398. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  399. Disable all rate limits, even if tasks has explicit rate limits set.
  400. .. _CELERY_ACKS_LATE:
  401. CELERY_ACKS_LATE
  402. ~~~~~~~~~~~~~~~~
  403. Late ack means the task messages will be acknowledged **after** the task
  404. has been executed, not *just before*, which is the default behavior.
  405. .. seealso::
  406. FAQ: :ref:`faq-acks_late-vs-retry`.
  407. .. _conf-celeryd:
  408. Worker: celeryd
  409. ---------------
  410. .. _CELERY_IMPORTS:
  411. CELERY_IMPORTS
  412. ~~~~~~~~~~~~~~
  413. A sequence of modules to import when the celery daemon starts.
  414. This is used to specify the task modules to import, but also
  415. to import signal handlers and additional remote control commands, etc.
  416. .. _CELERYD_MAX_TASKS_PER_CHILD:
  417. CELERYD_MAX_TASKS_PER_CHILD
  418. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  419. Maximum number of tasks a pool worker process can execute before
  420. it's replaced with a new one. Default is no limit.
  421. .. _CELERYD_TASK_TIME_LIMIT:
  422. CELERYD_TASK_TIME_LIMIT
  423. ~~~~~~~~~~~~~~~~~~~~~~~
  424. Task hard time limit in seconds. The worker processing the task will
  425. be killed and replaced with a new one when this is exceeded.
  426. .. _CELERYD_SOFT_TASK_TIME_LIMIT:
  427. CELERYD_SOFT_TASK_TIME_LIMIT
  428. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  429. Task soft time limit in seconds.
  430. The :exc:`~celery.exceptions.SoftTimeLimitExceeded` exception will be
  431. raised when this is exceeded. The task can catch this to
  432. e.g. clean up before the hard time limit comes.
  433. Example:
  434. .. code-block:: python
  435. from celery.decorators import task
  436. from celery.exceptions import SoftTimeLimitExceeded
  437. @task()
  438. def mytask():
  439. try:
  440. return do_work()
  441. except SoftTimeLimitExceeded:
  442. cleanup_in_a_hurry()
  443. .. _CELERY_STORE_ERRORS_EVEN_IF_IGNORED:
  444. CELERY_STORE_ERRORS_EVEN_IF_IGNORED
  445. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  446. If set, the worker stores all task errors in the result store even if
  447. :attr:`Task.ignore_result <celery.task.base.Task.ignore_result>` is on.
  448. .. _conf-error-mails:
  449. Error E-Mails
  450. -------------
  451. .. _CELERYD_SEND_TASK_ERROR_EMAILS:
  452. CELERY_SEND_TASK_ERROR_EMAILS
  453. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  454. If set to ``True``, errors in tasks will be sent to admins by e-mail.
  455. .. _ADMINS:
  456. ADMINS
  457. ~~~~~~
  458. List of ``(name, email_address)`` tuples for the admins that should
  459. receive error e-mails.
  460. .. _SERVER_EMAIL:
  461. SERVER_EMAIL
  462. ~~~~~~~~~~~~
  463. The e-mail address this worker sends e-mails from.
  464. Default is celery@localhost.
  465. .. _MAIL_HOST:
  466. MAIL_HOST
  467. ~~~~~~~~~
  468. The mail server to use. Default is ``"localhost"``.
  469. .. _MAIL_HOST_USER:
  470. MAIL_HOST_USER
  471. ~~~~~~~~~~~~~~
  472. Username (if required) to log on to the mail server with.
  473. .. _MAIL_HOST_PASSWORD:
  474. MAIL_HOST_PASSWORD
  475. ~~~~~~~~~~~~~~~~~~
  476. Password (if required) to log on to the mail server with.
  477. .. _MAIL_PORT:
  478. MAIL_PORT
  479. ~~~~~~~~~
  480. The port the mail server is listening on. Default is ``25``.
  481. .. _conf-example-error-mail-config:
  482. Example E-Mail configuration
  483. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  484. This configuration enables the sending of error e-mails to
  485. george@vandelay.com and kramer@vandelay.com:
  486. .. code-block:: python
  487. # Enables error e-mails.
  488. CELERY_SEND_TASK_ERROR_EMAILS = True
  489. # Name and e-mail addresses of recipients
  490. ADMINS = (
  491. ("George Costanza", "george@vandelay.com"),
  492. ("Cosmo Kramer", "kosmo@vandelay.com"),
  493. )
  494. # E-mail address used as sender (From field).
  495. SERVER_EMAIL = "no-reply@vandelay.com"
  496. # Mailserver configuration
  497. EMAIL_HOST = "mail.vandelay.com"
  498. EMAIL_PORT = 25
  499. # EMAIL_HOST_USER = "servers"
  500. # EMAIL_HOST_PASSWORD = "s3cr3t"
  501. .. _conf-events:
  502. Events
  503. ------
  504. .. _CELERY_SEND_EVENTS:
  505. CELERY_SEND_EVENTS
  506. ~~~~~~~~~~~~~~~~~~
  507. Send events so the worker can be monitored by tools like ``celerymon``.
  508. .. _CELERY_EVENT_EXCHANGE:
  509. CELERY_EVENT_EXCHANGE
  510. ~~~~~~~~~~~~~~~~~~~~~
  511. Name of the exchange to send event messages to. Default is ``"celeryevent"``.
  512. .. _CELERY_EVENT_EXCHANGE_TYPE:
  513. CELERY_EVENT_EXCHANGE_TYPE
  514. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  515. The exchange type of the event exchange. Default is to use a ``"direct"``
  516. exchange.
  517. .. _CELERY_EVENT_ROUTING_KEY:
  518. CELERY_EVENT_ROUTING_KEY
  519. ~~~~~~~~~~~~~~~~~~~~~~~~
  520. Routing key used when sending event messages. Default is ``"celeryevent"``.
  521. .. _CELERY_EVENT_SERIALIZER:
  522. CELERY_EVENT_SERIALIZER
  523. ~~~~~~~~~~~~~~~~~~~~~~~
  524. Message serialization format used when sending event messages.
  525. Default is ``"json"``.
  526. .. _conf-broadcast:
  527. Broadcast Commands
  528. ------------------
  529. .. _CELERY_BROADCAST_QUEUE:
  530. CELERY_BROADCAST_QUEUE
  531. ~~~~~~~~~~~~~~~~~~~~~~
  532. Name prefix for the queue used when listening for broadcast messages.
  533. The workers hostname will be appended to the prefix to create the final
  534. queue name.
  535. Default is ``"celeryctl"``.
  536. .. _CELERY_BROADCASTS_EXCHANGE:
  537. CELERY_BROADCAST_EXCHANGE
  538. ~~~~~~~~~~~~~~~~~~~~~~~~~
  539. Name of the exchange used for broadcast messages.
  540. Default is ``"celeryctl"``.
  541. .. _CELERY_BROADCAST_EXCHANGE_TYPE:
  542. CELERY_BROADCAST_EXCHANGE_TYPE
  543. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  544. Exchange type used for broadcast messages. Default is ``"fanout"``.
  545. .. _conf-logging:
  546. Logging
  547. -------
  548. .. _CELERYD_LOG_FILE:
  549. CELERYD_LOG_FILE
  550. ~~~~~~~~~~~~~~~~
  551. The default file name the worker daemon logs messages to. Can be overridden
  552. using the :option:`--logfile` option to :mod:`~celery.bin.celeryd`.
  553. The default is :const:`None` (``stderr``)
  554. .. _CELERYD_LOG_LEVEL:
  555. CELERYD_LOG_LEVEL
  556. ~~~~~~~~~~~~~~~~~
  557. Worker log level, can be any of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  558. :const:`ERROR` or :const:`CRITICAL`.
  559. Can also be set via the :option:`--loglevel` argument to
  560. :mod:`~celery.bin.celeryd`.
  561. See the :mod:`logging` module for more information.
  562. .. _CELERYD_LOG_FORMAT:
  563. CELERYD_LOG_FORMAT
  564. ~~~~~~~~~~~~~~~~~~
  565. The format to use for log messages.
  566. Default is ``[%(asctime)s: %(levelname)s/%(processName)s] %(message)s``
  567. See the Python :mod:`logging` module for more information about log
  568. formats.
  569. .. _CELERYD_TASK_LOG_FORMAT:
  570. CELERYD_TASK_LOG_FORMAT
  571. ~~~~~~~~~~~~~~~~~~~~~~~
  572. The format to use for log messages logged in tasks. Can be overridden using
  573. the :option:`--loglevel` option to :mod:`~celery.bin.celeryd`.
  574. Default is::
  575. [%(asctime)s: %(levelname)s/%(processName)s]
  576. [%(task_name)s(%(task_id)s)] %(message)s
  577. See the Python :mod:`logging` module for more information about log
  578. formats.
  579. .. _conf-custom-components:
  580. Custom Component Classes (advanced)
  581. -----------------------------------
  582. .. _CELERYD_POOL:
  583. CELERYD_POOL
  584. ~~~~~~~~~~~~
  585. Name of the task pool class used by the worker.
  586. Default is :class:`celery.concurrency.processes.TaskPool`.
  587. .. _CELERYD_LISTENER:
  588. CELERYD_LISTENER
  589. ~~~~~~~~~~~~~~~~
  590. Name of the listener class used by the worker.
  591. Default is :class:`celery.worker.listener.CarrotListener`.
  592. .. _CELERYD_MEDIATOR:
  593. CELERYD_MEDIATOR
  594. ~~~~~~~~~~~~~~~~
  595. Name of the mediator class used by the worker.
  596. Default is :class:`celery.worker.controllers.Mediator`.
  597. .. _CELERYD_ETA_SCHEDULER:
  598. CELERYD_ETA_SCHEDULER
  599. ~~~~~~~~~~~~~~~~~~~~~
  600. Name of the ETA scheduler class used by the worker.
  601. Default is :class:`celery.worker.controllers.ScheduleController`.
  602. .. _conf-celerybeat:
  603. Periodic Task Server: celerybeat
  604. --------------------------------
  605. .. _CELERYBEAT_SCHEDULE:
  606. CELERYBEAT_SCHEDULE
  607. ~~~~~~~~~~~~~~~~~~~
  608. The periodic task schedule used by :mod:`~celery.bin.celerybeat`.
  609. See :ref:`beat-entries`.
  610. .. _CELERYBEAT_SCHEDULE_FILENAME:
  611. CELERYBEAT_SCHEDULE_FILENAME
  612. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  613. Name of the file used to stores the last run times.
  614. Can be a relative or absolute path, but be aware that the suffix ``.db``
  615. may be appended to the file name (depending on Python version).
  616. Can also be set via the :option:`--schedule` argument to
  617. :mod:`~celery.bin.celerybeat`.
  618. .. _CELERYBEAT_MAX_LOOP_INTERVAL:
  619. CELERYBEAT_MAX_LOOP_INTERVAL
  620. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  621. The maximum number of seconds :mod:`~celery.bin.celerybeat` can sleep
  622. between checking the schedule. Default is 300 seconds (5 minutes).
  623. .. _CELERYBEAT_LOG_FILE:
  624. CELERYBEAT_LOG_FILE
  625. ~~~~~~~~~~~~~~~~~~~
  626. The default file name to log messages to. Can be overridden using
  627. the `--logfile`` option to :mod:`~celery.bin.celerybeat`.
  628. The default is :const:`None` (``stderr``).
  629. .. _CELERYBEAT_LOG_LEVEL:
  630. CELERYBEAT_LOG_LEVEL
  631. ~~~~~~~~~~~~~~~~~~~~
  632. Logging level. Can be any of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  633. :const:`ERROR`, or :const:`CRITICAL`.
  634. Can also be set via the :option:`--loglevel` argument to
  635. :mod:`~celery.bin.celerybeat`.
  636. See the :mod:`logging` module for more information.
  637. .. _conf-celerymon:
  638. Monitor Server: celerymon
  639. -------------------------
  640. .. _CELERYMON_LOG_FILE:
  641. CELERYMON_LOG_FILE
  642. ~~~~~~~~~~~~~~~~~~
  643. The default file name to log messages to. Can be overridden using
  644. the :option:`--logfile` argument to ``celerymon``.
  645. The default is :const:`None` (``stderr``)
  646. .. _CELERYMON_LOG_LEVEL:
  647. CELERYMON_LOG_LEVEL
  648. ~~~~~~~~~~~~~~~~~~~
  649. Logging level. Can be any of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  650. :const:`ERROR`, or :const:`CRITICAL`.
  651. See the :mod:`logging` module for more information.