configuration.rst 27 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186
  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. .. setting:: 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. .. setting:: 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. .. setting:: 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. .. setting:: 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. .. setting:: 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. .. setting:: 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. .. setting:: CELERY_RESULT_EXCHANGE
  136. CELERY_RESULT_EXCHANGE
  137. ~~~~~~~~~~~~~~~~~~~~~~
  138. Name of the exchange to publish results in. Default is ``"celeryresults"``.
  139. .. setting:: 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. .. setting:: CELERY_RESULT_SERIALIZER
  145. CELERY_RESULT_SERIALIZER
  146. ~~~~~~~~~~~~~~~~~~~~~~~~
  147. Result message serialization format. Default is ``"pickle"``. See
  148. :ref:`executing-serializers`.
  149. .. setting:: CELERY_RESULT_PERSISTENT
  150. CELERY_RESULT_PERSISTENT
  151. ~~~~~~~~~~~~~~~~~~~~~~~~
  152. If set to :const:`True`, result messages will be persistent. This means the
  153. messages will not be lost after a broker restart. The default is for the
  154. results to be transient.
  155. Example configuration
  156. ~~~~~~~~~~~~~~~~~~~~~
  157. .. code-block:: python
  158. CELERY_RESULT_BACKEND = "amqp"
  159. CELERY_AMQP_TASK_RESULT_EXPIRES = 18000 # 5 hours.
  160. .. _conf-cache-result-backend:
  161. Cache backend settings
  162. ----------------------
  163. .. note::
  164. The cache backend supports the `pylibmc`_ and `python-memcached`
  165. libraries. The latter is used only if `pylibmc`_ is not installed.
  166. .. setting:: CELERY_CACHE_BACKEND
  167. CELERY_CACHE_BACKEND
  168. ~~~~~~~~~~~~~~~~~~~~
  169. Using a single memcached server:
  170. .. code-block:: python
  171. CELERY_CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
  172. Using multiple memcached servers:
  173. .. code-block:: python
  174. CELERY_RESULT_BACKEND = "cache"
  175. CELERY_CACHE_BACKEND = 'memcached://172.19.26.240:11211;172.19.26.242:11211/'
  176. .. setting:: CELERY_CACHE_BACKEND_OPTIONS
  177. CELERY_CACHE_BACKEND_OPTIONS
  178. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  179. You can set pylibmc options using the :setting:`CELERY_CACHE_BACKEND_OPTIONS`
  180. setting:
  181. .. code-block:: python
  182. CELERY_CACHE_BACKEND_OPTIONS = {"binary": True,
  183. "behaviors": {"tcp_nodelay": True}}
  184. .. _`pylibmc`: http://sendapatch.se/projects/pylibmc/
  185. .. _conf-tyrant-result-backend:
  186. Tokyo Tyrant backend settings
  187. -----------------------------
  188. .. note::
  189. The Tokyo Tyrant backend requires the :mod:`pytyrant` library:
  190. http://pypi.python.org/pypi/pytyrant/
  191. This backend requires the following configuration directives to be set:
  192. .. setting:: TT_HOST
  193. TT_HOST
  194. ~~~~~~~
  195. Hostname of the Tokyo Tyrant server.
  196. .. setting:: TT_PORT
  197. TT_PORT
  198. ~~~~~~~
  199. The port the Tokyo Tyrant server is listening to.
  200. Example configuration
  201. ~~~~~~~~~~~~~~~~~~~~~
  202. .. code-block:: python
  203. CELERY_RESULT_BACKEND = "tyrant"
  204. TT_HOST = "localhost"
  205. TT_PORT = 1978
  206. .. _conf-redis-result-backend:
  207. Redis backend settings
  208. ----------------------
  209. .. note::
  210. The Redis backend requires the :mod:`redis` library:
  211. http://pypi.python.org/pypi/redis/0.5.5
  212. To install the redis package use ``pip`` or ``easy_install``::
  213. $ pip install redis
  214. This backend requires the following configuration directives to be set.
  215. .. setting:: REDIS_HOST
  216. REDIS_HOST
  217. ~~~~~~~~~~
  218. Hostname of the Redis database server. e.g. ``"localhost"``.
  219. .. setting:: REDIS_PORT
  220. REDIS_PORT
  221. ~~~~~~~~~~
  222. Port to the Redis database server. e.g. ``6379``.
  223. .. setting:: REDIS_DB
  224. REDIS_DB
  225. ~~~~~~~~
  226. Database number to use. Default is 0
  227. .. setting:: REDIS_PASSWORD
  228. REDIS_PASSWORD
  229. ~~~~~~~~~~~~~~
  230. Password used to connect to the database.
  231. Example configuration
  232. ~~~~~~~~~~~~~~~~~~~~~
  233. .. code-block:: python
  234. CELERY_RESULT_BACKEND = "redis"
  235. REDIS_HOST = "localhost"
  236. REDIS_PORT = 6379
  237. REDIS_DB = 0
  238. REDIS_CONNECT_RETRY = True
  239. .. _conf-mongodb-result-backend:
  240. MongoDB backend settings
  241. ------------------------
  242. .. note::
  243. The MongoDB backend requires the :mod:`pymongo` library:
  244. http://github.com/mongodb/mongo-python-driver/tree/master
  245. .. setting:: CELERY_MONGODB_BACKEND_SETTINGS
  246. CELERY_MONGODB_BACKEND_SETTINGS
  247. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248. This is a dict supporting the following keys:
  249. * host
  250. Hostname of the MongoDB server. Defaults to "localhost".
  251. * port
  252. The port the MongoDB server is listening to. Defaults to 27017.
  253. * user
  254. User name to authenticate to the MongoDB server as (optional).
  255. * password
  256. Password to authenticate to the MongoDB server (optional).
  257. * database
  258. The database name to connect to. Defaults to "celery".
  259. * taskmeta_collection
  260. The collection name to store task meta data.
  261. Defaults to "celery_taskmeta".
  262. .. _example-mongodb-result-config:
  263. Example configuration
  264. ~~~~~~~~~~~~~~~~~~~~~
  265. .. code-block:: python
  266. CELERY_RESULT_BACKEND = "mongodb"
  267. CELERY_MONGODB_BACKEND_SETTINGS = {
  268. "host": "192.168.1.100",
  269. "port": 30000,
  270. "database": "mydb",
  271. "taskmeta_collection": "my_taskmeta_collection",
  272. }
  273. .. _conf-messaging:
  274. Message Routing
  275. ---------------
  276. .. _conf-messaging-routing:
  277. .. setting:: CELERY_QUEUES
  278. CELERY_QUEUES
  279. ~~~~~~~~~~~~~
  280. The mapping of queues the worker consumes from. This is a dictionary
  281. of queue name/options. See :ref:`guide-routing` for more information.
  282. The default is a queue/exchange/binding key of ``"celery"``, with
  283. exchange type ``direct``.
  284. You don't have to care about this unless you want custom routing facilities.
  285. .. setting:: CELERY_ROUTES
  286. CELERY_ROUTES
  287. ~~~~~~~~~~~~~
  288. A list of routers, or a single router used to route tasks to queues.
  289. When deciding the final destination of a task the routers are consulted
  290. in order. See :ref:`routers` for more information.
  291. .. setting:: CELERY_CREATE_MISSING_QUEUES
  292. CELERY_CREATE_MISSING_QUEUES
  293. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  294. If enabled (default), any queues specified that is not defined in
  295. :setting:`CELERY_QUEUES` will be automatically created. See
  296. :ref:`routing-automatic`.
  297. .. setting:: CELERY_DEFAULT_QUEUE
  298. CELERY_DEFAULT_QUEUE
  299. ~~~~~~~~~~~~~~~~~~~~
  300. The queue used by default, if no custom queue is specified. This queue must
  301. be listed in :setting:`CELERY_QUEUES`. The default is: ``celery``.
  302. .. seealso::
  303. :ref:`routing-changing-default-queue`
  304. .. setting:: CELERY_DEFAULT_EXCHANGE
  305. CELERY_DEFAULT_EXCHANGE
  306. ~~~~~~~~~~~~~~~~~~~~~~~
  307. Name of the default exchange to use when no custom exchange is
  308. specified. The default is: ``celery``.
  309. .. setting:: CELERY_DEFAULT_EXCHANGE_TYPE
  310. CELERY_DEFAULT_EXCHANGE_TYPE
  311. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  312. Default exchange type used when no custom exchange is specified.
  313. The default is: ``direct``.
  314. .. setting:: CELERY_DEFAULT_ROUTING_KEY
  315. CELERY_DEFAULT_ROUTING_KEY
  316. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  317. The default routing key used when sending tasks.
  318. The default is: ``celery``.
  319. .. setting:: CELERY_DEFAULT_DELIVERY_MODE
  320. CELERY_DEFAULT_DELIVERY_MODE
  321. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  322. Can be ``transient`` or ``persistent``. The default is to send
  323. persistent messages.
  324. .. _conf-broker-connection:
  325. Broker Settings
  326. ---------------
  327. .. setting:: BROKER_BACKEND
  328. BROKER_BACKEND
  329. ~~~~~~~~~~~~~~
  330. The messaging backend to use. Default is ``"amqplib"``.
  331. .. setting:: BROKER_HOST
  332. BROKER_HOST
  333. ~~~~~~~~~~~
  334. Hostname of the broker.
  335. .. setting:: BROKER_PORT
  336. BROKER_PORT
  337. ~~~~~~~~~~~
  338. Custom port of the broker. Default is to use the default port for the
  339. selected backend.
  340. .. setting:: BROKER_USER
  341. BROKER_USER
  342. ~~~~~~~~~~~
  343. Username to connect as.
  344. .. setting:: BROKER_PASSWORD
  345. BROKER_PASSWORD
  346. ~~~~~~~~~~~~~~~
  347. Password to connect with.
  348. .. setting:: BROKER_VHOST
  349. BROKER_VHOST
  350. ~~~~~~~~~~~~
  351. Virtual host. Default is ``"/"``.
  352. .. setting:: BROKER_USE_SSL
  353. BROKER_USE_SSL
  354. ~~~~~~~~~~~~~~
  355. Use SSL to conenct to the broker. Off by defalt. This may not be supported
  356. by all transports.
  357. .. setting:: BROKER_CONNECTION_TIMEOUT
  358. BROKER_CONNECTION_TIMEOUT
  359. ~~~~~~~~~~~~~~~~~~~~~~~~~
  360. The default timeout in seconds before we give up establishing a connection
  361. to the AMQP server. Default is 4 seconds.
  362. .. setting:: CELERY_BROKER_CONNECTION_RETRY
  363. BROKER_CONNECTION_RETRY
  364. ~~~~~~~~~~~~~~~~~~~~~~~
  365. Automatically try to re-establish the connection to the AMQP broker if lost.
  366. The time between retries is increased for each retry, and is
  367. not exhausted before :setting:`CELERY_BROKER_CONNECTION_MAX_RETRIES` is
  368. exceeded.
  369. This behavior is on by default.
  370. .. setting:: CELERY_BROKER_CONNECTION_MAX_RETRIES
  371. CELERY_BROKER_CONNECTION_MAX_RETRIES
  372. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  373. Maximum number of retries before we give up re-establishing a connection
  374. to the AMQP broker.
  375. If this is set to :const:`0` or :const:`None`, we will retry forever.
  376. Default is 100 retries.
  377. .. _conf-task-execution:
  378. Task execution settings
  379. -----------------------
  380. .. setting:: CELERY_ALWAYS_EAGER
  381. CELERY_ALWAYS_EAGER
  382. ~~~~~~~~~~~~~~~~~~~
  383. If this is :const:`True`, all tasks will be executed locally by blocking
  384. until it is finished. ``apply_async`` and ``Task.delay`` will return
  385. a :class:`~celery.result.EagerResult` which emulates the behavior of
  386. :class:`~celery.result.AsyncResult`, except the result has already
  387. been evaluated.
  388. Tasks will never be sent to the queue, but executed locally
  389. instead.
  390. .. setting:: CELERY_EAGER_PROPAGATES_EXCEPTIONS
  391. CELERY_EAGER_PROPAGATES_EXCEPTIONS
  392. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  393. If this is :const:`True`, eagerly executed tasks (using ``.apply``, or with
  394. :setting:`CELERY_ALWAYS_EAGER` on), will raise exceptions.
  395. It's the same as always running ``apply`` with ``throw=True``.
  396. .. setting:: CELERY_IGNORE_RESULT
  397. CELERY_IGNORE_RESULT
  398. ~~~~~~~~~~~~~~~~~~~~
  399. Whether to store the task return values or not (tombstones).
  400. If you still want to store errors, just not successful return values,
  401. you can set :setting:`CELERY_STORE_ERRORS_EVEN_IF_IGNORED`.
  402. .. setting:: CELERY_TASK_RESULT_EXPIRES
  403. CELERY_TASK_RESULT_EXPIRES
  404. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  405. Time (in seconds, or a :class:`~datetime.timedelta` object) for when after
  406. stored task tombstones will be deleted.
  407. A built-in periodic task will delete the results after this time
  408. (:class:`celery.task.builtins.backend_cleanup`).
  409. .. note::
  410. For the moment this only works with the database, cache, redis and MongoDB
  411. backends. For the AMQP backend see
  412. :setting:`CELERY_AMQP_TASK_RESULT_EXPIRES`.
  413. When using the database or MongoDB backends, ``celerybeat`` must be
  414. running for the results to be expired.
  415. .. setting:: CELERY_MAX_CACHED_RESULTS
  416. CELERY_MAX_CACHED_RESULTS
  417. ~~~~~~~~~~~~~~~~~~~~~~~~~
  418. Total number of results to store before results are evicted from the
  419. result cache. The default is 5000.
  420. .. setting:: CELERY_TRACK_STARTED
  421. CELERY_TRACK_STARTED
  422. ~~~~~~~~~~~~~~~~~~~~
  423. If :const:`True` the task will report its status as "started" when the
  424. task is executed by a worker. The default value is :const:`False` as
  425. the normal behaviour is to not report that level of granularity. Tasks
  426. are either pending, finished, or waiting to be retried. Having a "started"
  427. state can be useful for when there are long running tasks and there is a
  428. need to report which task is currently running.
  429. .. setting:: CELERY_TASK_SERIALIZER
  430. CELERY_TASK_SERIALIZER
  431. ~~~~~~~~~~~~~~~~~~~~~~
  432. A string identifying the default serialization method to use. Can be
  433. ``pickle`` (default), ``json``, ``yaml``, or any custom serialization
  434. methods that have been registered with :mod:`kombu.serialization.registry`.
  435. .. seealso::
  436. :ref:`executing-serializers`.
  437. .. setting:: CELERY_DEFAULT_RATE_LIMIT
  438. CELERY_DEFAULT_RATE_LIMIT
  439. ~~~~~~~~~~~~~~~~~~~~~~~~~
  440. The global default rate limit for tasks.
  441. This value is used for tasks that does not have a custom rate limit
  442. The default is no rate limit.
  443. .. setting:: CELERY_DISABLE_RATE_LIMITS
  444. CELERY_DISABLE_RATE_LIMITS
  445. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  446. Disable all rate limits, even if tasks has explicit rate limits set.
  447. .. setting:: CELERY_ACKS_LATE
  448. CELERY_ACKS_LATE
  449. ~~~~~~~~~~~~~~~~
  450. Late ack means the task messages will be acknowledged **after** the task
  451. has been executed, not *just before*, which is the default behavior.
  452. .. seealso::
  453. FAQ: :ref:`faq-acks_late-vs-retry`.
  454. .. _conf-celeryd:
  455. Worker: celeryd
  456. ---------------
  457. .. setting:: CELERY_IMPORTS
  458. CELERY_IMPORTS
  459. ~~~~~~~~~~~~~~
  460. A sequence of modules to import when the celery daemon starts.
  461. This is used to specify the task modules to import, but also
  462. to import signal handlers and additional remote control commands, etc.
  463. .. setting:: CELERYD_MAX_TASKS_PER_CHILD
  464. CELERYD_MAX_TASKS_PER_CHILD
  465. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  466. Maximum number of tasks a pool worker process can execute before
  467. it's replaced with a new one. Default is no limit.
  468. .. setting:: CELERYD_TASK_TIME_LIMIT
  469. CELERYD_TASK_TIME_LIMIT
  470. ~~~~~~~~~~~~~~~~~~~~~~~
  471. Task hard time limit in seconds. The worker processing the task will
  472. be killed and replaced with a new one when this is exceeded.
  473. .. setting:: CELERYD_TASK_SOFT_TIME_LIMIT
  474. CELERYD_TASK_SOFT_TIME_LIMIT
  475. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  476. Task soft time limit in seconds.
  477. The :exc:`~celery.exceptions.SoftTimeLimitExceeded` exception will be
  478. raised when this is exceeded. The task can catch this to
  479. e.g. clean up before the hard time limit comes.
  480. Example:
  481. .. code-block:: python
  482. from celery.decorators import task
  483. from celery.exceptions import SoftTimeLimitExceeded
  484. @task()
  485. def mytask():
  486. try:
  487. return do_work()
  488. except SoftTimeLimitExceeded:
  489. cleanup_in_a_hurry()
  490. .. setting:: CELERY_STORE_ERRORS_EVEN_IF_IGNORED
  491. CELERY_STORE_ERRORS_EVEN_IF_IGNORED
  492. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  493. If set, the worker stores all task errors in the result store even if
  494. :attr:`Task.ignore_result <celery.task.base.Task.ignore_result>` is on.
  495. .. setting:: CELERYD_STATE_DB
  496. CELERYD_STATE_DB
  497. ~~~~~~~~~~~~~~~~
  498. Name of the file used to stores persistent worker state (like revoked tasks).
  499. Can be a relative or absolute path, but be aware that the suffix ``.db``
  500. may be appended to the file name (depending on Python version).
  501. Can also be set via the :option:`--statedb` argument to
  502. :mod:`~celery.bin.celeryd`.
  503. Not enabled by default.
  504. .. setting:: CELERYD_ETA_SCHEDULER_PRECISION
  505. CELERYD_ETA_SCHEDULER_PRECISION
  506. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  507. Set the maximum time in seconds that the ETA scheduler can sleep between
  508. rechecking the schedule. Default is 1 second.
  509. Setting this value to 1 second means the schedulers precision will
  510. be 1 second. If you need near millisecond precision you can set this to 0.1.
  511. .. _conf-error-mails:
  512. Error E-Mails
  513. -------------
  514. .. setting:: CELERYD_SEND_TASK_ERROR_EMAILS
  515. CELERY_SEND_TASK_ERROR_EMAILS
  516. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  517. The default value for the ``Task.send_error_emails`` attribute, which if
  518. set to :const:`True` means errors occuring during task execution will be
  519. sent to :setting:`ADMINS` by e-mail.
  520. .. setting:: CELERY_TASK_ERROR_WHITELIST
  521. CELERY_TASK_ERROR_WHITELIST
  522. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  523. A whitelist of exceptions to send error e-mails for.
  524. .. setting:: ADMINS
  525. ADMINS
  526. ~~~~~~
  527. List of ``(name, email_address)`` tuples for the admins that should
  528. receive error e-mails.
  529. .. setting:: SERVER_EMAIL
  530. SERVER_EMAIL
  531. ~~~~~~~~~~~~
  532. The e-mail address this worker sends e-mails from.
  533. Default is celery@localhost.
  534. .. setting:: MAIL_HOST
  535. MAIL_HOST
  536. ~~~~~~~~~
  537. The mail server to use. Default is ``"localhost"``.
  538. .. setting:: MAIL_HOST_USER
  539. MAIL_HOST_USER
  540. ~~~~~~~~~~~~~~
  541. Username (if required) to log on to the mail server with.
  542. .. setting:: MAIL_HOST_PASSWORD
  543. MAIL_HOST_PASSWORD
  544. ~~~~~~~~~~~~~~~~~~
  545. Password (if required) to log on to the mail server with.
  546. .. setting:: MAIL_PORT
  547. MAIL_PORT
  548. ~~~~~~~~~
  549. The port the mail server is listening on. Default is ``25``.
  550. .. _conf-example-error-mail-config:
  551. Example E-Mail configuration
  552. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  553. This configuration enables the sending of error e-mails to
  554. george@vandelay.com and kramer@vandelay.com:
  555. .. code-block:: python
  556. # Enables error e-mails.
  557. CELERY_SEND_TASK_ERROR_EMAILS = True
  558. # Name and e-mail addresses of recipients
  559. ADMINS = (
  560. ("George Costanza", "george@vandelay.com"),
  561. ("Cosmo Kramer", "kosmo@vandelay.com"),
  562. )
  563. # E-mail address used as sender (From field).
  564. SERVER_EMAIL = "no-reply@vandelay.com"
  565. # Mailserver configuration
  566. EMAIL_HOST = "mail.vandelay.com"
  567. EMAIL_PORT = 25
  568. # EMAIL_HOST_USER = "servers"
  569. # EMAIL_HOST_PASSWORD = "s3cr3t"
  570. .. _conf-events:
  571. Events
  572. ------
  573. .. setting:: CELERY_SEND_EVENTS
  574. CELERY_SEND_EVENTS
  575. ~~~~~~~~~~~~~~~~~~
  576. Send events so the worker can be monitored by tools like ``celerymon``.
  577. .. setting:: CELERY_EVENT_QUEUE
  578. CELERY_EVENT_QUEUE
  579. ~~~~~~~~~~~~~~~~~~
  580. Name of the queue to consume event messages from. Default is
  581. ``"celeryevent"``.
  582. .. setting:: CELERY_EVENT_EXCHANGE
  583. CELERY_EVENT_EXCHANGE
  584. ~~~~~~~~~~~~~~~~~~~~~
  585. Name of the exchange to send event messages to. Default is ``"celeryevent"``.
  586. .. setting:: CELERY_EVENT_EXCHANGE_TYPE
  587. CELERY_EVENT_EXCHANGE_TYPE
  588. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  589. The exchange type of the event exchange. Default is to use a ``"direct"``
  590. exchange.
  591. .. setting:: CELERY_EVENT_ROUTING_KEY
  592. CELERY_EVENT_ROUTING_KEY
  593. ~~~~~~~~~~~~~~~~~~~~~~~~
  594. Routing key used when sending event messages. Default is ``"celeryevent"``.
  595. .. setting:: CELERY_EVENT_SERIALIZER
  596. CELERY_EVENT_SERIALIZER
  597. ~~~~~~~~~~~~~~~~~~~~~~~
  598. Message serialization format used when sending event messages.
  599. Default is ``"json"``. See :ref:`executing-serializers`.
  600. .. _conf-broadcast:
  601. Broadcast Commands
  602. ------------------
  603. .. setting:: CELERY_BROADCAST_QUEUE
  604. CELERY_BROADCAST_QUEUE
  605. ~~~~~~~~~~~~~~~~~~~~~~
  606. Name prefix for the queue used when listening for broadcast messages.
  607. The workers hostname will be appended to the prefix to create the final
  608. queue name.
  609. Default is ``"celeryctl"``.
  610. .. setting:: CELERY_BROADCASTS_EXCHANGE
  611. CELERY_BROADCAST_EXCHANGE
  612. ~~~~~~~~~~~~~~~~~~~~~~~~~
  613. Name of the exchange used for broadcast messages.
  614. Default is ``"celeryctl"``.
  615. .. setting:: CELERY_BROADCAST_EXCHANGE_TYPE
  616. CELERY_BROADCAST_EXCHANGE_TYPE
  617. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  618. Exchange type used for broadcast messages. Default is ``"fanout"``.
  619. .. _conf-logging:
  620. Logging
  621. -------
  622. .. setting:: CELERYD_LOG_FILE
  623. CELERYD_LOG_FILE
  624. ~~~~~~~~~~~~~~~~
  625. The default file name the worker daemon logs messages to. Can be overridden
  626. using the :option:`--logfile` option to :mod:`~celery.bin.celeryd`.
  627. The default is :const:`None` (``stderr``)
  628. .. setting:: CELERYD_LOG_LEVEL
  629. CELERYD_LOG_LEVEL
  630. ~~~~~~~~~~~~~~~~~
  631. Worker log level, can be one of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  632. :const:`ERROR` or :const:`CRITICAL`.
  633. Can also be set via the :option:`--loglevel` argument to
  634. :mod:`~celery.bin.celeryd`.
  635. See the :mod:`logging` module for more information.
  636. .. setting:: CELERYD_LOG_FORMAT
  637. CELERYD_LOG_FORMAT
  638. ~~~~~~~~~~~~~~~~~~
  639. The format to use for log messages.
  640. Default is ``[%(asctime)s: %(levelname)s/%(processName)s] %(message)s``
  641. See the Python :mod:`logging` module for more information about log
  642. formats.
  643. .. setting:: CELERYD_TASK_LOG_FORMAT
  644. CELERYD_TASK_LOG_FORMAT
  645. ~~~~~~~~~~~~~~~~~~~~~~~
  646. The format to use for log messages logged in tasks. Can be overridden using
  647. the :option:`--loglevel` option to :mod:`~celery.bin.celeryd`.
  648. Default is::
  649. [%(asctime)s: %(levelname)s/%(processName)s]
  650. [%(task_name)s(%(task_id)s)] %(message)s
  651. See the Python :mod:`logging` module for more information about log
  652. formats.
  653. .. setting:: CELERY_REDIRECT_STDOUTS
  654. CELERY_REDIRECT_STDOUTS
  655. ~~~~~~~~~~~~~~~~~~~~~~~
  656. If enabled ``stdout`` and ``stderr`` will be redirected
  657. to the current logger.
  658. Enabled by default.
  659. Used by :program:`celeryd` and :program:`celerybeat`.
  660. .. setting:: CELERY_REDIRECT_STDOUTS_LEVEL
  661. CELERY_REDIRECT_STDOUTS_LEVEL
  662. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  663. The loglevel output to ``stdout`` and ``stderr`` is logged as.
  664. Can be one of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  665. :const:`ERROR` or :const:`CRITICAL`.
  666. Default is :const:`WARNING`.
  667. .. _conf-custom-components:
  668. Custom Component Classes (advanced)
  669. -----------------------------------
  670. .. setting:: CELERYD_POOL
  671. CELERYD_POOL
  672. ~~~~~~~~~~~~
  673. Name of the task pool class used by the worker.
  674. Default is :class:`celery.concurrency.processes.TaskPool`.
  675. .. setting:: CELERYD_LISTENER
  676. CELERYD_LISTENER
  677. ~~~~~~~~~~~~~~~~
  678. Name of the listener class used by the worker.
  679. Default is :class:`celery.worker.listener.CarrotListener`.
  680. .. setting:: CELERYD_MEDIATOR
  681. CELERYD_MEDIATOR
  682. ~~~~~~~~~~~~~~~~
  683. Name of the mediator class used by the worker.
  684. Default is :class:`celery.worker.controllers.Mediator`.
  685. .. setting:: CELERYD_ETA_SCHEDULER
  686. CELERYD_ETA_SCHEDULER
  687. ~~~~~~~~~~~~~~~~~~~~~
  688. Name of the ETA scheduler class used by the worker.
  689. Default is :class:`celery.worker.controllers.ScheduleController`.
  690. .. _conf-celerybeat:
  691. Periodic Task Server: celerybeat
  692. --------------------------------
  693. .. setting:: CELERYBEAT_SCHEDULE
  694. CELERYBEAT_SCHEDULE
  695. ~~~~~~~~~~~~~~~~~~~
  696. The periodic task schedule used by :mod:`~celery.bin.celerybeat`.
  697. See :ref:`beat-entries`.
  698. .. setting:: CELERYBEAT_SCHEDULER
  699. CELERYBEAT_SCHEDULER
  700. ~~~~~~~~~~~~~~~~~~~~
  701. The default scheduler class. Default is
  702. ``"celery.beat.PersistentScheduler"``.
  703. Can also be set via the :option:`-S` argument to
  704. :mod:`~celery.bin.celerybeat`.
  705. .. setting:: CELERYBEAT_SCHEDULE_FILENAME
  706. CELERYBEAT_SCHEDULE_FILENAME
  707. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  708. Name of the file used by ``PersistentScheduler`` to store the last run times
  709. of periodic tasks. Can be a relative or absolute path, but be aware that the
  710. suffix ``.db`` may be appended to the file name (depending on Python version).
  711. Can also be set via the :option:`--schedule` argument to
  712. :mod:`~celery.bin.celerybeat`.
  713. .. setting:: CELERYBEAT_MAX_LOOP_INTERVAL
  714. CELERYBEAT_MAX_LOOP_INTERVAL
  715. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  716. The maximum number of seconds :mod:`~celery.bin.celerybeat` can sleep
  717. between checking the schedule. Default is 300 seconds (5 minutes).
  718. .. setting:: CELERYBEAT_LOG_FILE
  719. CELERYBEAT_LOG_FILE
  720. ~~~~~~~~~~~~~~~~~~~
  721. The default file name to log messages to. Can be overridden using
  722. the `--logfile`` option to :mod:`~celery.bin.celerybeat`.
  723. The default is :const:`None` (``stderr``).
  724. .. setting:: CELERYBEAT_LOG_LEVEL
  725. CELERYBEAT_LOG_LEVEL
  726. ~~~~~~~~~~~~~~~~~~~~
  727. Logging level. Can be any of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  728. :const:`ERROR`, or :const:`CRITICAL`.
  729. Can also be set via the :option:`--loglevel` argument to
  730. :mod:`~celery.bin.celerybeat`.
  731. See the :mod:`logging` module for more information.
  732. .. _conf-celerymon:
  733. Monitor Server: celerymon
  734. -------------------------
  735. .. setting:: CELERYMON_LOG_FILE
  736. CELERYMON_LOG_FILE
  737. ~~~~~~~~~~~~~~~~~~
  738. The default file name to log messages to. Can be overridden using
  739. the :option:`--logfile` argument to ``celerymon``.
  740. The default is :const:`None` (``stderr``)
  741. .. setting:: CELERYMON_LOG_LEVEL
  742. CELERYMON_LOG_LEVEL
  743. ~~~~~~~~~~~~~~~~~~~
  744. Logging level. Can be any of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  745. :const:`ERROR`, or :const:`CRITICAL`.
  746. See the :mod:`logging` module for more information.