configuration.rst 42 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373137413751376137713781379138013811382138313841385138613871388138913901391139213931394139513961397139813991400140114021403140414051406140714081409141014111412141314141415141614171418141914201421142214231424142514261427142814291430143114321433143414351436143714381439144014411442144314441445144614471448144914501451145214531454145514561457145814591460146114621463146414651466146714681469147014711472147314741475147614771478147914801481148214831484148514861487148814891490149114921493149414951496149714981499150015011502150315041505150615071508150915101511151215131514151515161517151815191520152115221523152415251526152715281529153015311532153315341535153615371538153915401541154215431544154515461547154815491550155115521553155415551556155715581559156015611562156315641565156615671568156915701571157215731574157515761577157815791580158115821583158415851586158715881589159015911592159315941595159615971598159916001601160216031604160516061607160816091610161116121613161416151616161716181619162016211622162316241625162616271628162916301631163216331634163516361637163816391640164116421643164416451646164716481649165016511652165316541655165616571658165916601661166216631664166516661667166816691670167116721673167416751676167716781679168016811682168316841685168616871688168916901691169216931694
  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. ## Broker settings.
  18. BROKER_URL = "amqp://guest:guest@localhost:5672//"
  19. # List of modules to import when celery starts.
  20. CELERY_IMPORTS = ("myapp.tasks", )
  21. ## Using the database to store task state and results.
  22. CELERY_RESULT_BACKEND = "database"
  23. CELERY_RESULT_DBURI = "sqlite:///mydatabase.db"
  24. CELERY_ANNOTATIONS = {"tasks.add": {"rate_limit": "10/s"}}
  25. Configuration Directives
  26. ========================
  27. .. _conf-datetime:
  28. Time and date settings
  29. ----------------------
  30. .. setting:: CELERY_ENABLE_UTC
  31. CELERY_ENABLE_UTC
  32. ~~~~~~~~~~~~~~~~~
  33. .. versionadded:: 2.5
  34. If enabled dates and times in messages will be converted to use
  35. the UTC timezone.
  36. Note that workers running Celery versions below 2.5 will assume a local
  37. timezone for all messages, so only enable if all workers have been
  38. upgraded.
  39. Enabled by default since version 3.0.
  40. .. setting:: CELERY_TIMEZONE
  41. CELERY_TIMEZONE
  42. ---------------
  43. Configure Celery to use a custom time zone.
  44. The timezone value can be any time zone supported by the :mod:`pytz`
  45. library. :mod:`pytz` must be installed for the selected zone
  46. to be used.
  47. If not set then the systems default local time zone is used.
  48. .. warning::
  49. Celery requires the :mod:`pytz` library to be installed,
  50. when using custom time zones (other than UTC). You can
  51. install it using :program:`pip` or :program:`easy_install`:
  52. .. code-block:: bash
  53. $ pip install pytz
  54. Pytz is a library that defines the timzones of the world,
  55. it changes quite frequently so it is not included in the Python Standard
  56. Library.
  57. .. _conf-tasks:
  58. Task settings
  59. -------------
  60. .. setting:: CELERY_ANNOTATIONS
  61. CELERY_ANNOTATIONS
  62. ~~~~~~~~~~~~~~~~~~
  63. This setting can be used to rewrite any task attribute from the
  64. configuration. The setting can be a dict, or a list of annotation
  65. objects that filter for tasks and return a map of attributes
  66. to change.
  67. This will change the ``rate_limit`` attribute for the ``tasks.add``
  68. task:
  69. .. code-block:: python
  70. CELERY_ANNOTATIONS = {"tasks.add": {"rate_limit": "10/s"}}
  71. or change the same for all tasks:
  72. .. code-block:: python
  73. CELERY_ANNOTATIONS = {"*": {"rate_limit": "10/s"}}
  74. You can change methods too, for example the ``on_failure`` handler:
  75. .. code-block:: python
  76. def my_on_failure(self, exc, task_id, args, kwargs, einfo):
  77. print("Oh no! Task failed: %r" % (exc, ))
  78. CELERY_ANNOTATIONS = {"*": {"on_failure": my_on_failure}}
  79. If you need more flexibility then you can use objects
  80. instead of a dict to choose which tasks to annotate:
  81. .. code-block:: python
  82. class MyAnnotate(object):
  83. def annotate(self, task):
  84. if task.name.startswith("tasks."):
  85. return {"rate_limit": "10/s"}
  86. CELERY_ANNOTATIONS = (MyAnnotate(), {...})
  87. .. _conf-concurrency:
  88. Concurrency settings
  89. --------------------
  90. .. setting:: CELERYD_CONCURRENCY
  91. CELERYD_CONCURRENCY
  92. ~~~~~~~~~~~~~~~~~~~
  93. The number of concurrent worker processes/threads/green threads executing
  94. tasks.
  95. If you're doing mostly I/O you can have more processes,
  96. but if mostly CPU-bound, try to keep it close to the
  97. number of CPUs on your machine. If not set, the number of CPUs/cores
  98. on the host will be used.
  99. Defaults to the number of available CPUs.
  100. .. setting:: CELERYD_PREFETCH_MULTIPLIER
  101. CELERYD_PREFETCH_MULTIPLIER
  102. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  103. How many messages to prefetch at a time multiplied by the number of
  104. concurrent processes. The default is 4 (four messages for each
  105. process). The default setting is usually a good choice, however -- if you
  106. have very long running tasks waiting in the queue and you have to start the
  107. workers, note that the first worker to start will receive four times the
  108. number of messages initially. Thus the tasks may not be fairly distributed
  109. to the workers.
  110. .. _conf-result-backend:
  111. Task result backend settings
  112. ----------------------------
  113. .. setting:: CELERY_RESULT_BACKEND
  114. CELERY_RESULT_BACKEND
  115. ~~~~~~~~~~~~~~~~~~~~~
  116. :Deprecated aliases: ``CELERY_BACKEND``
  117. The backend used to store task results (tombstones).
  118. Disabled by default.
  119. Can be one of the following:
  120. * database
  121. Use a relational database supported by `SQLAlchemy`_.
  122. See :ref:`conf-database-result-backend`.
  123. * cache
  124. Use `memcached`_ to store the results.
  125. See :ref:`conf-cache-result-backend`.
  126. * mongodb
  127. Use `MongoDB`_ to store the results.
  128. See :ref:`conf-mongodb-result-backend`.
  129. * redis
  130. Use `Redis`_ to store the results.
  131. See :ref:`conf-redis-result-backend`.
  132. * amqp
  133. Send results back as AMQP messages
  134. See :ref:`conf-amqp-result-backend`.
  135. * cassandra
  136. Use `Cassandra`_ to store the results.
  137. See :ref:`conf-cassandra-result-backend`.
  138. * ironcache
  139. Use `IronCache`_ to store the results.
  140. See :ref:`conf-ironcache-result-backend`.
  141. .. warning:
  142. While the AMQP result backend is very efficient, you must make sure
  143. you only receive the same result once. See :doc:`userguide/calling`).
  144. .. _`SQLAlchemy`: http://sqlalchemy.org
  145. .. _`memcached`: http://memcached.org
  146. .. _`MongoDB`: http://mongodb.org
  147. .. _`Redis`: http://code.google.com/p/redis/
  148. .. _`Cassandra`: http://cassandra.apache.org/
  149. .. setting:: CELERY_RESULT_SERIALIZER
  150. CELERY_RESULT_SERIALIZER
  151. ~~~~~~~~~~~~~~~~~~~~~~~~
  152. Result serialization format. Default is `"pickle"`. See
  153. :ref:`calling-serializers` for information about supported
  154. serialization formats.
  155. .. _conf-database-result-backend:
  156. Database backend settings
  157. -------------------------
  158. .. setting:: CELERY_RESULT_DBURI
  159. CELERY_RESULT_DBURI
  160. ~~~~~~~~~~~~~~~~~~~
  161. Please see `Supported Databases`_ for a table of supported databases.
  162. To use this backend you need to configure it with an
  163. `Connection String`_, some examples include:
  164. .. code-block:: python
  165. # sqlite (filename)
  166. CELERY_RESULT_DBURI = "sqlite:///celerydb.sqlite"
  167. # mysql
  168. CELERY_RESULT_DBURI = "mysql://scott:tiger@localhost/foo"
  169. # postgresql
  170. CELERY_RESULT_DBURI = "postgresql://scott:tiger@localhost/mydatabase"
  171. # oracle
  172. CELERY_RESULT_DBURI = "oracle://scott:tiger@127.0.0.1:1521/sidname"
  173. See `Connection String`_ for more information about connection
  174. strings.
  175. .. setting:: CELERY_RESULT_ENGINE_OPTIONS
  176. CELERY_RESULT_ENGINE_OPTIONS
  177. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  178. To specify additional SQLAlchemy database engine options you can use
  179. the :setting:`CELERY_RESULT_ENGINE_OPTIONS` setting::
  180. # echo enables verbose logging from SQLAlchemy.
  181. CELERY_RESULT_ENGINE_OPTIONS = {"echo": True}
  182. .. setting:: CELERY_RESULT_DB_SHORT_LIVED_SESSIONS
  183. CELERY_RESULT_DB_SHORT_LIVED_SESSIONS = True
  184. Short lived sessions are disabled by default. If enabled they can drastically reduce
  185. performance, especially on systems processing lots of tasks. This option is useful
  186. on low-traffic workers that experience errors as a result of cached database connections
  187. going stale through inactivity. For example, intermittent errors like
  188. `(OperationalError) (2006, 'MySQL server has gone away')` can be fixed by enabling
  189. short lived sessions. This option only affects the database backend.
  190. .. _`Supported Databases`:
  191. http://www.sqlalchemy.org/docs/core/engines.html#supported-databases
  192. .. _`Connection String`:
  193. http://www.sqlalchemy.org/docs/core/engines.html#database-urls
  194. Example configuration
  195. ~~~~~~~~~~~~~~~~~~~~~
  196. .. code-block:: python
  197. CELERY_RESULT_BACKEND = "database"
  198. CELERY_RESULT_DBURI = "mysql://user:password@host/dbname"
  199. .. _conf-amqp-result-backend:
  200. AMQP backend settings
  201. ---------------------
  202. .. note::
  203. The AMQP backend requires RabbitMQ 1.1.0 or higher to automatically
  204. expire results. If you are running an older version of RabbitmQ
  205. you should disable result expiration like this:
  206. CELERY_TASK_RESULT_EXPIRES = None
  207. .. setting:: CELERY_RESULT_EXCHANGE
  208. CELERY_RESULT_EXCHANGE
  209. ~~~~~~~~~~~~~~~~~~~~~~
  210. Name of the exchange to publish results in. Default is `"celeryresults"`.
  211. .. setting:: CELERY_RESULT_EXCHANGE_TYPE
  212. CELERY_RESULT_EXCHANGE_TYPE
  213. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  214. The exchange type of the result exchange. Default is to use a `direct`
  215. exchange.
  216. .. setting:: CELERY_RESULT_PERSISTENT
  217. CELERY_RESULT_PERSISTENT
  218. ~~~~~~~~~~~~~~~~~~~~~~~~
  219. If set to :const:`True`, result messages will be persistent. This means the
  220. messages will not be lost after a broker restart. The default is for the
  221. results to be transient.
  222. Example configuration
  223. ~~~~~~~~~~~~~~~~~~~~~
  224. .. code-block:: python
  225. CELERY_RESULT_BACKEND = "amqp"
  226. CELERY_TASK_RESULT_EXPIRES = 18000 # 5 hours.
  227. .. _conf-cache-result-backend:
  228. Cache backend settings
  229. ----------------------
  230. .. note::
  231. The cache backend supports the `pylibmc`_ and `python-memcached`
  232. libraries. The latter is used only if `pylibmc`_ is not installed.
  233. .. setting:: CELERY_CACHE_BACKEND
  234. CELERY_CACHE_BACKEND
  235. ~~~~~~~~~~~~~~~~~~~~
  236. Using a single memcached server:
  237. .. code-block:: python
  238. CELERY_CACHE_BACKEND = 'memcached://127.0.0.1:11211/'
  239. Using multiple memcached servers:
  240. .. code-block:: python
  241. CELERY_RESULT_BACKEND = "cache"
  242. CELERY_CACHE_BACKEND = 'memcached://172.19.26.240:11211;172.19.26.242:11211/'
  243. .. setting:: CELERY_CACHE_BACKEND_OPTIONS
  244. The "memory" backend stores the cache in memory only:
  245. CELERY_CACHE_BACKEND = "memory"
  246. CELERY_CACHE_BACKEND_OPTIONS
  247. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  248. You can set pylibmc options using the :setting:`CELERY_CACHE_BACKEND_OPTIONS`
  249. setting:
  250. .. code-block:: python
  251. CELERY_CACHE_BACKEND_OPTIONS = {"binary": True,
  252. "behaviors": {"tcp_nodelay": True}}
  253. .. _`pylibmc`: http://sendapatch.se/projects/pylibmc/
  254. .. _conf-redis-result-backend:
  255. Redis backend settings
  256. ----------------------
  257. Configuring the backend URL
  258. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  259. .. note::
  260. The Redis backend requires the :mod:`redis` library:
  261. http://pypi.python.org/pypi/redis/
  262. To install the redis package use `pip` or `easy_install`:
  263. .. code-block:: bash
  264. $ pip install redis
  265. This backend requires the :setting:`CELERY_RESULT_BACKEND`
  266. setting to be set to a Redis URL::
  267. CELERY_RESULT_BACKEND = "redis://:password@host:port/db"
  268. For example::
  269. CELERY_RESULT_BACKEND = "redis://localhost/0"
  270. which is the same as::
  271. CELERY_RESULT_BACKEND = "redis://"
  272. The fields of the URL is defined as folows:
  273. - *host*
  274. Host name or IP address of the Redis server. e.g. `"localhost"`.
  275. - *port*
  276. Port to the Redis server. Default is 6379.
  277. - *db*
  278. Database number to use. Default is 0.
  279. The db can include an optional leading slash.
  280. - *password*
  281. Password used to connect to the database.
  282. .. setting:: CELERY_REDIS_MAX_CONNECTIONS
  283. CELERY_REDIS_MAX_CONNECTIONS
  284. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  285. Maximum number of connections available in the Redis connection
  286. pool used for sending and retrieving results.
  287. .. _conf-mongodb-result-backend:
  288. MongoDB backend settings
  289. ------------------------
  290. .. note::
  291. The MongoDB backend requires the :mod:`pymongo` library:
  292. http://github.com/mongodb/mongo-python-driver/tree/master
  293. .. setting:: CELERY_MONGODB_BACKEND_SETTINGS
  294. CELERY_MONGODB_BACKEND_SETTINGS
  295. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  296. This is a dict supporting the following keys:
  297. * host
  298. Host name of the MongoDB server. Defaults to "localhost".
  299. * port
  300. The port the MongoDB server is listening to. Defaults to 27017.
  301. * user
  302. User name to authenticate to the MongoDB server as (optional).
  303. * password
  304. Password to authenticate to the MongoDB server (optional).
  305. * database
  306. The database name to connect to. Defaults to "celery".
  307. * taskmeta_collection
  308. The collection name to store task meta data.
  309. Defaults to "celery_taskmeta".
  310. * max_pool_size
  311. Passed as max_pool_size to PyMongo's Connection or MongoClient
  312. constructor. It is the maximum number of TCP connections to keep
  313. open to MongoDB at a given time. If there are more open connections
  314. than max_pool_size, sockets will be closed when they are released.
  315. Defaults to 10.
  316. * options
  317. Additional keyword arguments to pass to the mongodb connection
  318. constructor. See the :mod:`pymongo` docs to see a list of arguments
  319. supported.
  320. .. _example-mongodb-result-config:
  321. Example configuration
  322. ~~~~~~~~~~~~~~~~~~~~~
  323. .. code-block:: python
  324. CELERY_RESULT_BACKEND = "mongodb"
  325. CELERY_MONGODB_BACKEND_SETTINGS = {
  326. "host": "192.168.1.100",
  327. "port": 30000,
  328. "database": "mydb",
  329. "taskmeta_collection": "my_taskmeta_collection",
  330. }
  331. .. _conf-cassandra-result-backend:
  332. Cassandra backend settings
  333. --------------------------
  334. .. note::
  335. The Cassandra backend requires the :mod:`pycassa` library:
  336. http://pypi.python.org/pypi/pycassa/
  337. To install the pycassa package use `pip` or `easy_install`:
  338. .. code-block:: bash
  339. $ pip install pycassa
  340. This backend requires the following configuration directives to be set.
  341. .. setting:: CASSANDRA_SERVERS
  342. CASSANDRA_SERVERS
  343. ~~~~~~~~~~~~~~~~~
  344. List of ``host:port`` Cassandra servers. e.g. ``["localhost:9160]"``.
  345. .. setting:: CASSANDRA_KEYSPACE
  346. CASSANDRA_KEYSPACE
  347. ~~~~~~~~~~~~~~~~~~
  348. The keyspace in which to store the results. e.g. ``"tasks_keyspace"``.
  349. .. setting:: CASSANDRA_COLUMN_FAMILY
  350. CASSANDRA_COLUMN_FAMILY
  351. ~~~~~~~~~~~~~~~~~~~~~~~
  352. The column family in which to store the results. eg ``"tasks"``
  353. .. setting:: CASSANDRA_READ_CONSISTENCY
  354. CASSANDRA_READ_CONSISTENCY
  355. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  356. The read consistency used. Values can be ``"ONE"``, ``"QUORUM"`` or ``"ALL"``.
  357. .. setting:: CASSANDRA_WRITE_CONSISTENCY
  358. CASSANDRA_WRITE_CONSISTENCY
  359. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  360. The write consistency used. Values can be ``"ONE"``, ``"QUORUM"`` or ``"ALL"``.
  361. .. setting:: CASSANDRA_DETAILED_MODE
  362. CASSANDRA_DETAILED_MODE
  363. ~~~~~~~~~~~~~~~~~~~~~~~
  364. Enable or disable detailed mode. Default is :const:`False`.
  365. This mode allows to use the power of Cassandra wide columns to
  366. store all states for a task as a wide column, instead of only the last one.
  367. To use this mode, you need to configure your ColumnFamily to
  368. use the ``TimeUUID`` type as a comparator::
  369. create column family task_results with comparator = TimeUUIDType;
  370. CASSANDRA_OPTIONS
  371. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  372. Options to be passed to the `pycassa connection pool`_ (optional).
  373. .. _`pycassa connection pool`: http://pycassa.github.com/pycassa/api/pycassa/pool.html
  374. Example configuration
  375. ~~~~~~~~~~~~~~~~~~~~~
  376. .. code-block:: python
  377. CASSANDRA_SERVERS = ["localhost:9160"]
  378. CASSANDRA_KEYSPACE = "celery"
  379. CASSANDRA_COLUMN_FAMILY = "task_results"
  380. CASSANDRA_READ_CONSISTENCY = "ONE"
  381. CASSANDRA_WRITE_CONSISTENCY = "ONE"
  382. CASSANDRA_DETAILED_MODE = True
  383. CASSANDRA_OPTIONS = {
  384. 'timeout': 300,
  385. 'max_retries': 10
  386. }
  387. .. _conf-ironcache-result-backend:
  388. IronCache backend settings
  389. --------------------------
  390. .. note::
  391. The Cassandra backend requires the :mod:`iron_celery` library:
  392. http://pypi.python.org/pypi/iron_celery
  393. To install the iron_celery package use `pip` or `easy_install`:
  394. .. code-block:: bash
  395. $ pip install iron_celery
  396. IronCache is configured via the URL provided in :setting:`CELERY_RESULT_BACKEND`, for example::
  397. CELERY_RESULT_BACKEND = 'ironcache://project_id:token@'
  398. Or to change the cache name::
  399. ironcache:://project_id:token@/awesomecache
  400. For more information, see: https://github.com/iron-io/iron_celery
  401. .. _conf-messaging:
  402. Message Routing
  403. ---------------
  404. .. _conf-messaging-routing:
  405. .. setting:: CELERY_QUEUES
  406. CELERY_QUEUES
  407. ~~~~~~~~~~~~~
  408. The mapping of queues the worker consumes from. This is a dictionary
  409. of queue name/options. See :ref:`guide-routing` for more information.
  410. The default is a queue/exchange/binding key of `"celery"`, with
  411. exchange type `direct`.
  412. You don't have to care about this unless you want custom routing facilities.
  413. .. setting:: CELERY_ROUTES
  414. CELERY_ROUTES
  415. ~~~~~~~~~~~~~
  416. A list of routers, or a single router used to route tasks to queues.
  417. When deciding the final destination of a task the routers are consulted
  418. in order. See :ref:`routers` for more information.
  419. .. setting:: CELERY_QUEUE_HA_POLICY
  420. CELERY_QUEUE_HA_POLICY
  421. ~~~~~~~~~~~~~~~~~~~~~~
  422. :brokers: RabbitMQ
  423. This will set the default HA policy for a queue, and the value
  424. can either be a string (usually ``all``):
  425. .. code-block:: python
  426. CELERY_QUEUE_HA_POLICY = 'all'
  427. Using 'all' will replicate the queue to all current nodes,
  428. Or you can give it a list of nodes to replicate to:
  429. .. code-block:: python
  430. CELERY_QUEUE_HA_POLICY = ['rabbit@host1', 'rabbit@host2']
  431. Using a list will implicitly set ``x-ha-policy`` to 'nodes' and
  432. ``x-ha-policy-params`` to the given list of nodes.
  433. See http://www.rabbitmq.com/ha.html for more information.
  434. .. setting:: CELERY_WORKER_DIRECT
  435. CELERY_WORKER_DIRECT
  436. ~~~~~~~~~~~~~~~~~~~~
  437. This option enables so that every worker has a dedicated queue,
  438. so that tasks can be routed to specific workers.
  439. The queue name for each worker is automatically generated based on
  440. the worker hostname and a ``.dq`` suffix, using the ``C.dq`` exchange.
  441. For example the queue name for the worker with hostname ``w1.example.com``
  442. becomes::
  443. w1.example.com.dq
  444. Then you can route the task to the task by specifying the hostname
  445. as the routung key and the ``C.dq`` exchange::
  446. CELERY_ROUTES = {
  447. 'tasks.add': {'exchange': 'C.dq', 'routing_key': 'w1.example.com'}
  448. }
  449. This setting is mandatory if you want to use the ``move_to_worker`` features
  450. of :mod:`celery.contrib.migrate`.
  451. .. setting:: CELERY_CREATE_MISSING_QUEUES
  452. CELERY_CREATE_MISSING_QUEUES
  453. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  454. If enabled (default), any queues specified that is not defined in
  455. :setting:`CELERY_QUEUES` will be automatically created. See
  456. :ref:`routing-automatic`.
  457. .. setting:: CELERY_DEFAULT_QUEUE
  458. CELERY_DEFAULT_QUEUE
  459. ~~~~~~~~~~~~~~~~~~~~
  460. The name of the default queue used by `.apply_async` if the message has
  461. no route or no custom queue has been specified.
  462. This queue must be listed in :setting:`CELERY_QUEUES`.
  463. If :setting:`CELERY_QUEUES` is not specified then it this automatically
  464. created containing one queue entry, where this name is used as the name of
  465. that queue.
  466. The default is: `celery`.
  467. .. seealso::
  468. :ref:`routing-changing-default-queue`
  469. .. setting:: CELERY_DEFAULT_EXCHANGE
  470. CELERY_DEFAULT_EXCHANGE
  471. ~~~~~~~~~~~~~~~~~~~~~~~
  472. Name of the default exchange to use when no custom exchange is
  473. specified for a key in the :setting:`CELERY_QUEUES` setting.
  474. The default is: `celery`.
  475. .. setting:: CELERY_DEFAULT_EXCHANGE_TYPE
  476. CELERY_DEFAULT_EXCHANGE_TYPE
  477. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  478. Default exchange type used when no custom exchange type is specified.
  479. for a key in the :setting:`CELERY_QUEUES` setting.
  480. The default is: `direct`.
  481. .. setting:: CELERY_DEFAULT_ROUTING_KEY
  482. CELERY_DEFAULT_ROUTING_KEY
  483. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  484. The default routing key used when no custom routing key
  485. is specified for a key in the :setting:`CELERY_QUEUES` setting.
  486. The default is: `celery`.
  487. .. setting:: CELERY_DEFAULT_DELIVERY_MODE
  488. CELERY_DEFAULT_DELIVERY_MODE
  489. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  490. Can be `transient` or `persistent`. The default is to send
  491. persistent messages.
  492. .. _conf-broker-settings:
  493. Broker Settings
  494. ---------------
  495. .. setting:: BROKER_TRANSPORT
  496. BROKER_TRANSPORT
  497. ~~~~~~~~~~~~~~~~
  498. :Aliases: ``BROKER_BACKEND``
  499. :Deprecated aliases: ``CARROT_BACKEND``
  500. .. setting:: BROKER_URL
  501. BROKER_URL
  502. ~~~~~~~~~~
  503. Default broker URL. This must be an URL in the form of::
  504. transport://userid:password@hostname:port/virtual_host
  505. Only the scheme part (``transport://``) is required, the rest
  506. is optional, and defaults to the specific transports default values.
  507. The transport part is the broker implementation to use, and the
  508. default is ``amqp``, which uses ``librabbitmq`` by default or falls back to
  509. ``pyamqp`` if that is not installed. Also there are many other choices including
  510. ``redis``, ``beanstalk``, ``sqlalchemy``, ``django``, ``mongodb``,
  511. ``couchdb``.
  512. It can also be a fully qualified path to your own transport implementation.
  513. See the Kombu documentation for more information about broker URLs.
  514. .. setting:: BROKER_HEARTBEAT
  515. BROKER_HEARTBEAT
  516. ~~~~~~~~~~~~~~~~
  517. :transports supported: ``pyamqp``
  518. It's not always possible to detect connection loss in a timely
  519. manner using TCP/IP alone, so AMQP defines something called heartbeats
  520. that's is used both by the client and the broker to detect if
  521. a connection was closed.
  522. Hartbeats are disabled by default.
  523. If the heartbeat value is 10 seconds, then
  524. the heartbeat will be monitored at the interval specified
  525. by the :setting:`BROKER_HEARTBEAT_CHECKRATE` setting, which by default is
  526. double the rate of the heartbeat value
  527. (so for the default 10 seconds, the heartbeat is checked every 5 seconds).
  528. .. setting:: BROKER_HEARTBEAT_CHECKRATE
  529. BROKER_HEARTBEAT_CHECKRATE
  530. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  531. :transports supported: ``pyamqp``
  532. At intervals the worker will monitor that the broker has not missed
  533. too many heartbeats. The rate at which this is checked is calculated
  534. by dividing the :setting:`BROKER_HEARTBEAT` value with this value,
  535. so if the heartbeat is 10.0 and the rate is the default 2.0, the check
  536. will be performed every 5 seconds (twice the heartbeat sending rate).
  537. .. setting:: BROKER_USE_SSL
  538. BROKER_USE_SSL
  539. ~~~~~~~~~~~~~~
  540. Use SSL to connect to the broker. Off by default. This may not be supported
  541. by all transports.
  542. .. setting:: BROKER_POOL_LIMIT
  543. BROKER_POOL_LIMIT
  544. ~~~~~~~~~~~~~~~~~
  545. .. versionadded:: 2.3
  546. The maximum number of connections that can be open in the connection pool.
  547. The pool is enabled by default since version 2.5, with a default limit of ten
  548. connections. This number can be tweaked depending on the number of
  549. threads/greenthreads (eventlet/gevent) using a connection. For example
  550. running eventlet with 1000 greenlets that use a connection to the broker,
  551. contention can arise and you should consider increasing the limit.
  552. If set to :const:`None` or 0 the connection pool will be disabled and
  553. connections will be established and closed for every use.
  554. Default (since 2.5) is to use a pool of 10 connections.
  555. .. setting:: BROKER_CONNECTION_TIMEOUT
  556. BROKER_CONNECTION_TIMEOUT
  557. ~~~~~~~~~~~~~~~~~~~~~~~~~
  558. The default timeout in seconds before we give up establishing a connection
  559. to the AMQP server. Default is 4 seconds.
  560. .. setting:: BROKER_CONNECTION_RETRY
  561. BROKER_CONNECTION_RETRY
  562. ~~~~~~~~~~~~~~~~~~~~~~~
  563. Automatically try to re-establish the connection to the AMQP broker if lost.
  564. The time between retries is increased for each retry, and is
  565. not exhausted before :setting:`BROKER_CONNECTION_MAX_RETRIES` is
  566. exceeded.
  567. This behavior is on by default.
  568. .. setting:: BROKER_CONNECTION_MAX_RETRIES
  569. BROKER_CONNECTION_MAX_RETRIES
  570. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  571. Maximum number of retries before we give up re-establishing a connection
  572. to the AMQP broker.
  573. If this is set to :const:`0` or :const:`None`, we will retry forever.
  574. Default is 100 retries.
  575. .. setting:: BROKER_TRANSPORT_OPTIONS
  576. BROKER_TRANSPORT_OPTIONS
  577. ~~~~~~~~~~~~~~~~~~~~~~~~
  578. .. versionadded:: 2.2
  579. A dict of additional options passed to the underlying transport.
  580. See your transport user manual for supported options (if any).
  581. Example setting the visibility timeout (supported by Redis and SQS
  582. transports):
  583. .. code-block:: python
  584. BROKER_TRANSPORT_OPTIONS = {'visibility_timeout': 18000} # 5 hours
  585. .. _conf-task-execution:
  586. Task execution settings
  587. -----------------------
  588. .. setting:: CELERY_ALWAYS_EAGER
  589. CELERY_ALWAYS_EAGER
  590. ~~~~~~~~~~~~~~~~~~~
  591. If this is :const:`True`, all tasks will be executed locally by blocking until
  592. the task returns. ``apply_async()`` and ``Task.delay()`` will return
  593. an :class:`~celery.result.EagerResult` instance, which emulates the API
  594. and behavior of :class:`~celery.result.AsyncResult`, except the result
  595. is already evaluated.
  596. That is, tasks will be executed locally instead of being sent to
  597. the queue.
  598. .. setting:: CELERY_EAGER_PROPAGATES_EXCEPTIONS
  599. CELERY_EAGER_PROPAGATES_EXCEPTIONS
  600. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  601. If this is :const:`True`, eagerly executed tasks (applied by `task.apply()`,
  602. or when the :setting:`CELERY_ALWAYS_EAGER` setting is enabled), will
  603. propagate exceptions.
  604. It's the same as always running ``apply()`` with ``throw=True``.
  605. .. setting:: CELERY_IGNORE_RESULT
  606. CELERY_IGNORE_RESULT
  607. ~~~~~~~~~~~~~~~~~~~~
  608. Whether to store the task return values or not (tombstones).
  609. If you still want to store errors, just not successful return values,
  610. you can set :setting:`CELERY_STORE_ERRORS_EVEN_IF_IGNORED`.
  611. .. setting:: CELERY_MESSAGE_COMPRESSION
  612. CELERY_MESSAGE_COMPRESSION
  613. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  614. Default compression used for task messages.
  615. Can be ``"gzip"``, ``"bzip2"`` (if available), or any custom
  616. compression schemes registered in the Kombu compression registry.
  617. The default is to send uncompressed messages.
  618. .. setting:: CELERY_TASK_RESULT_EXPIRES
  619. CELERY_TASK_RESULT_EXPIRES
  620. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  621. Time (in seconds, or a :class:`~datetime.timedelta` object) for when after
  622. stored task tombstones will be deleted.
  623. A built-in periodic task will delete the results after this time
  624. (:class:`celery.task.backend_cleanup`).
  625. Default is to expire after 1 day.
  626. .. note::
  627. For the moment this only works with the amqp, database, cache, redis and MongoDB
  628. backends.
  629. When using the database or MongoDB backends, `celerybeat` must be
  630. running for the results to be expired.
  631. .. setting:: CELERY_MAX_CACHED_RESULTS
  632. CELERY_MAX_CACHED_RESULTS
  633. ~~~~~~~~~~~~~~~~~~~~~~~~~
  634. Result backends caches ready results used by the client.
  635. This is the total number of results to cache before older results are evicted.
  636. The default is 5000.
  637. .. setting:: CELERY_CHORD_PROPAGATES
  638. CELERY_CHORD_PROPAGATES
  639. ~~~~~~~~~~~~~~~~~~~~~~~
  640. .. versionadded:: 3.0.14
  641. This setting defines what happens when a task part of a chord raises an
  642. exception:
  643. - If propagate is True the chord callback will change state to FAILURE
  644. with the exception value set to a :exc:`~celery.exceptions.ChordError`
  645. instance containing information about the error and the task that failed.
  646. This is the default behavior in Celery 3.1+
  647. - If propagate is False the exception value will instead be forwarded
  648. to the chord callback.
  649. This was the default behavior before version 3.1.
  650. .. setting:: CELERY_TRACK_STARTED
  651. CELERY_TRACK_STARTED
  652. ~~~~~~~~~~~~~~~~~~~~
  653. If :const:`True` the task will report its status as "started" when the
  654. task is executed by a worker. The default value is :const:`False` as
  655. the normal behaviour is to not report that level of granularity. Tasks
  656. are either pending, finished, or waiting to be retried. Having a "started"
  657. state can be useful for when there are long running tasks and there is a
  658. need to report which task is currently running.
  659. .. setting:: CELERY_TASK_SERIALIZER
  660. CELERY_TASK_SERIALIZER
  661. ~~~~~~~~~~~~~~~~~~~~~~
  662. A string identifying the default serialization method to use. Can be
  663. `pickle` (default), `json`, `yaml`, `msgpack` or any custom serialization
  664. methods that have been registered with :mod:`kombu.serialization.registry`.
  665. .. seealso::
  666. :ref:`calling-serializers`.
  667. .. setting:: CELERY_TASK_PUBLISH_RETRY
  668. CELERY_TASK_PUBLISH_RETRY
  669. ~~~~~~~~~~~~~~~~~~~~~~~~~
  670. .. versionadded:: 2.2
  671. Decides if publishing task messages will be retried in the case
  672. of connection loss or other connection errors.
  673. See also :setting:`CELERY_TASK_PUBLISH_RETRY_POLICY`.
  674. Enabled by default.
  675. .. setting:: CELERY_TASK_PUBLISH_RETRY_POLICY
  676. CELERY_TASK_PUBLISH_RETRY_POLICY
  677. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  678. .. versionadded:: 2.2
  679. Defines the default policy when retrying publishing a task message in
  680. the case of connection loss or other connection errors.
  681. See :ref:`calling-retry` for more information.
  682. .. setting:: CELERY_DEFAULT_RATE_LIMIT
  683. CELERY_DEFAULT_RATE_LIMIT
  684. ~~~~~~~~~~~~~~~~~~~~~~~~~
  685. The global default rate limit for tasks.
  686. This value is used for tasks that does not have a custom rate limit
  687. The default is no rate limit.
  688. .. setting:: CELERY_DISABLE_RATE_LIMITS
  689. CELERY_DISABLE_RATE_LIMITS
  690. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  691. Disable all rate limits, even if tasks has explicit rate limits set.
  692. .. setting:: CELERY_ACKS_LATE
  693. CELERY_ACKS_LATE
  694. ~~~~~~~~~~~~~~~~
  695. Late ack means the task messages will be acknowledged **after** the task
  696. has been executed, not *just before*, which is the default behavior.
  697. .. seealso::
  698. FAQ: :ref:`faq-acks_late-vs-retry`.
  699. .. _conf-celeryd:
  700. Worker: celeryd
  701. ---------------
  702. .. setting:: CELERY_IMPORTS
  703. CELERY_IMPORTS
  704. ~~~~~~~~~~~~~~
  705. A sequence of modules to import when the worker starts.
  706. This is used to specify the task modules to import, but also
  707. to import signal handlers and additional remote control commands, etc.
  708. The modules will be imported in the original order.
  709. .. setting:: CELERY_INCLUDE
  710. CELERY_INCLUDE
  711. ~~~~~~~~~~~~~~
  712. Exact same semantics as :setting:`CELERY_IMPORTS`, but can be used as a means
  713. to have different import categories.
  714. The modules in this setting are imported after the modules in
  715. :setting:`CELERY_IMPORTS`.
  716. .. setting:: CELERYD_FORCE_EXECV
  717. CELERYD_FORCE_EXECV
  718. ~~~~~~~~~~~~~~~~~~~
  719. On Unix the processes pool will fork, so that child processes
  720. start with the same memory as the parent process.
  721. This can cause problems as there is a known deadlock condition
  722. with pthread locking primitives when `fork()` is combined with threads.
  723. You should enable this setting if you are experiencing hangs (deadlocks),
  724. especially in combination with time limits or having a max tasks per child limit.
  725. This option will be enabled by default in a later version.
  726. This is not a problem on Windows, as it does not have `fork()`.
  727. .. setting:: CELERYD_WORKER_LOST_WAIT
  728. CELERYD_WORKER_LOST_WAIT
  729. ~~~~~~~~~~~~~~~~~~~~~~~~
  730. In some cases a worker may be killed without proper cleanup,
  731. and the worker may have published a result before terminating.
  732. This value specifies how long we wait for any missing results before
  733. raising a :exc:`@WorkerLostError` exception.
  734. Default is 10.0
  735. .. setting:: CELERYD_MAX_TASKS_PER_CHILD
  736. CELERYD_MAX_TASKS_PER_CHILD
  737. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  738. Maximum number of tasks a pool worker process can execute before
  739. it's replaced with a new one. Default is no limit.
  740. .. setting:: CELERYD_TASK_TIME_LIMIT
  741. CELERYD_TASK_TIME_LIMIT
  742. ~~~~~~~~~~~~~~~~~~~~~~~
  743. Task hard time limit in seconds. The worker processing the task will
  744. be killed and replaced with a new one when this is exceeded.
  745. .. setting:: CELERYD_TASK_SOFT_TIME_LIMIT
  746. CELERYD_TASK_SOFT_TIME_LIMIT
  747. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  748. Task soft time limit in seconds.
  749. The :exc:`~@SoftTimeLimitExceeded` exception will be
  750. raised when this is exceeded. The task can catch this to
  751. e.g. clean up before the hard time limit comes.
  752. Example:
  753. .. code-block:: python
  754. from celery.exceptions import SoftTimeLimitExceeded
  755. @celery.task
  756. def mytask():
  757. try:
  758. return do_work()
  759. except SoftTimeLimitExceeded:
  760. cleanup_in_a_hurry()
  761. .. setting:: CELERY_STORE_ERRORS_EVEN_IF_IGNORED
  762. CELERY_STORE_ERRORS_EVEN_IF_IGNORED
  763. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  764. If set, the worker stores all task errors in the result store even if
  765. :attr:`Task.ignore_result <celery.task.base.Task.ignore_result>` is on.
  766. .. setting:: CELERYD_STATE_DB
  767. CELERYD_STATE_DB
  768. ~~~~~~~~~~~~~~~~
  769. Name of the file used to stores persistent worker state (like revoked tasks).
  770. Can be a relative or absolute path, but be aware that the suffix `.db`
  771. may be appended to the file name (depending on Python version).
  772. Can also be set via the :option:`--statedb` argument to
  773. :mod:`~celery.bin.celeryd`.
  774. Not enabled by default.
  775. .. setting:: CELERYD_TIMER_PRECISION
  776. CELERYD_TIMER_PRECISION
  777. ~~~~~~~~~~~~~~~~~~~~~~~
  778. Set the maximum time in seconds that the ETA scheduler can sleep between
  779. rechecking the schedule. Default is 1 second.
  780. Setting this value to 1 second means the schedulers precision will
  781. be 1 second. If you need near millisecond precision you can set this to 0.1.
  782. .. _conf-error-mails:
  783. Error E-Mails
  784. -------------
  785. .. setting:: CELERY_SEND_TASK_ERROR_EMAILS
  786. CELERY_SEND_TASK_ERROR_EMAILS
  787. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  788. The default value for the `Task.send_error_emails` attribute, which if
  789. set to :const:`True` means errors occurring during task execution will be
  790. sent to :setting:`ADMINS` by email.
  791. Disabled by default.
  792. .. setting:: ADMINS
  793. ADMINS
  794. ~~~~~~
  795. List of `(name, email_address)` tuples for the administrators that should
  796. receive error emails.
  797. .. setting:: SERVER_EMAIL
  798. SERVER_EMAIL
  799. ~~~~~~~~~~~~
  800. The email address this worker sends emails from.
  801. Default is celery@localhost.
  802. .. setting:: EMAIL_HOST
  803. EMAIL_HOST
  804. ~~~~~~~~~~
  805. The mail server to use. Default is `"localhost"`.
  806. .. setting:: EMAIL_HOST_USER
  807. EMAIL_HOST_USER
  808. ~~~~~~~~~~~~~~~
  809. User name (if required) to log on to the mail server with.
  810. .. setting:: EMAIL_HOST_PASSWORD
  811. EMAIL_HOST_PASSWORD
  812. ~~~~~~~~~~~~~~~~~~~
  813. Password (if required) to log on to the mail server with.
  814. .. setting:: EMAIL_PORT
  815. EMAIL_PORT
  816. ~~~~~~~~~~
  817. The port the mail server is listening on. Default is `25`.
  818. .. setting:: EMAIL_USE_SSL
  819. EMAIL_USE_SSL
  820. ~~~~~~~~~~~~~
  821. Use SSL when connecting to the SMTP server. Disabled by default.
  822. .. setting:: EMAIL_USE_TLS
  823. EMAIL_USE_TLS
  824. ~~~~~~~~~~~~~
  825. Use TLS when connecting to the SMTP server. Disabled by default.
  826. .. setting:: EMAIL_TIMEOUT
  827. EMAIL_TIMEOUT
  828. ~~~~~~~~~~~~~
  829. Timeout in seconds for when we give up trying to connect
  830. to the SMTP server when sending emails.
  831. The default is 2 seconds.
  832. .. _conf-example-error-mail-config:
  833. Example E-Mail configuration
  834. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  835. This configuration enables the sending of error emails to
  836. george@vandelay.com and kramer@vandelay.com:
  837. .. code-block:: python
  838. # Enables error emails.
  839. CELERY_SEND_TASK_ERROR_EMAILS = True
  840. # Name and email addresses of recipients
  841. ADMINS = (
  842. ("George Costanza", "george@vandelay.com"),
  843. ("Cosmo Kramer", "kosmo@vandelay.com"),
  844. )
  845. # Email address used as sender (From field).
  846. SERVER_EMAIL = "no-reply@vandelay.com"
  847. # Mailserver configuration
  848. EMAIL_HOST = "mail.vandelay.com"
  849. EMAIL_PORT = 25
  850. # EMAIL_HOST_USER = "servers"
  851. # EMAIL_HOST_PASSWORD = "s3cr3t"
  852. .. _conf-events:
  853. Events
  854. ------
  855. .. setting:: CELERY_SEND_EVENTS
  856. CELERY_SEND_EVENTS
  857. ~~~~~~~~~~~~~~~~~~
  858. Send events so the worker can be monitored by tools like `celerymon`.
  859. .. setting:: CELERY_SEND_TASK_SENT_EVENT
  860. CELERY_SEND_TASK_SENT_EVENT
  861. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  862. .. versionadded:: 2.2
  863. If enabled, a :event:`task-sent` event will be sent for every task so tasks can be
  864. tracked before they are consumed by a worker.
  865. Disabled by default.
  866. .. setting:: CELERY_EVENT_SERIALIZER
  867. CELERY_EVENT_SERIALIZER
  868. ~~~~~~~~~~~~~~~~~~~~~~~
  869. Message serialization format used when sending event messages.
  870. Default is `"json"`. See :ref:`calling-serializers`.
  871. .. _conf-broadcast:
  872. Broadcast Commands
  873. ------------------
  874. .. setting:: CELERY_BROADCAST_QUEUE
  875. CELERY_BROADCAST_QUEUE
  876. ~~~~~~~~~~~~~~~~~~~~~~
  877. Name prefix for the queue used when listening for broadcast messages.
  878. The workers host name will be appended to the prefix to create the final
  879. queue name.
  880. Default is `"celeryctl"`.
  881. .. setting:: CELERY_BROADCAST_EXCHANGE
  882. CELERY_BROADCAST_EXCHANGE
  883. ~~~~~~~~~~~~~~~~~~~~~~~~~
  884. Name of the exchange used for broadcast messages.
  885. Default is `"celeryctl"`.
  886. .. setting:: CELERY_BROADCAST_EXCHANGE_TYPE
  887. CELERY_BROADCAST_EXCHANGE_TYPE
  888. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  889. Exchange type used for broadcast messages. Default is `"fanout"`.
  890. .. _conf-logging:
  891. Logging
  892. -------
  893. .. setting:: CELERYD_HIJACK_ROOT_LOGGER
  894. CELERYD_HIJACK_ROOT_LOGGER
  895. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  896. .. versionadded:: 2.2
  897. By default any previously configured logging options will be reset,
  898. because the Celery programs "hijacks" the root logger.
  899. If you want to customize your own logging then you can disable
  900. this behavior.
  901. .. note::
  902. Logging can also be customized by connecting to the
  903. :signal:`celery.signals.setup_logging` signal.
  904. .. setting:: CELERYD_LOG_COLOR
  905. CELERYD_LOG_COLOR
  906. ~~~~~~~~~~~~~~~~~
  907. Enables/disables colors in logging output by the Celery apps.
  908. By default colors are enabled if
  909. 1) the app is logging to a real terminal, and not a file.
  910. 2) the app is not running on Windows.
  911. .. setting:: CELERYD_LOG_FORMAT
  912. CELERYD_LOG_FORMAT
  913. ~~~~~~~~~~~~~~~~~~
  914. The format to use for log messages.
  915. Default is `[%(asctime)s: %(levelname)s/%(processName)s] %(message)s`
  916. See the Python :mod:`logging` module for more information about log
  917. formats.
  918. .. setting:: CELERYD_TASK_LOG_FORMAT
  919. CELERYD_TASK_LOG_FORMAT
  920. ~~~~~~~~~~~~~~~~~~~~~~~
  921. The format to use for log messages logged in tasks. Can be overridden using
  922. the :option:`--loglevel` option to :mod:`~celery.bin.celeryd`.
  923. Default is::
  924. [%(asctime)s: %(levelname)s/%(processName)s]
  925. [%(task_name)s(%(task_id)s)] %(message)s
  926. See the Python :mod:`logging` module for more information about log
  927. formats.
  928. .. setting:: CELERY_REDIRECT_STDOUTS
  929. CELERY_REDIRECT_STDOUTS
  930. ~~~~~~~~~~~~~~~~~~~~~~~
  931. If enabled `stdout` and `stderr` will be redirected
  932. to the current logger.
  933. Enabled by default.
  934. Used by :program:`celeryd` and :program:`celerybeat`.
  935. .. setting:: CELERY_REDIRECT_STDOUTS_LEVEL
  936. CELERY_REDIRECT_STDOUTS_LEVEL
  937. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  938. The log level output to `stdout` and `stderr` is logged as.
  939. Can be one of :const:`DEBUG`, :const:`INFO`, :const:`WARNING`,
  940. :const:`ERROR` or :const:`CRITICAL`.
  941. Default is :const:`WARNING`.
  942. .. _conf-security:
  943. Security
  944. --------
  945. .. setting:: CELERY_SECURITY_KEY
  946. CELERY_SECURITY_KEY
  947. ~~~~~~~~~~~~~~~~~~~
  948. .. versionadded:: 2.5
  949. The relative or absolute path to a file containing the private key
  950. used to sign messages when :ref:`message-signing` is used.
  951. .. setting:: CELERY_SECURITY_CERTIFICATE
  952. CELERY_SECURITY_CERTIFICATE
  953. ~~~~~~~~~~~~~~~~~~~~~~~~~~~
  954. .. versionadded:: 2.5
  955. The relative or absolute path to an X.509 certificate file
  956. used to sign messages when :ref:`message-signing` is used.
  957. .. setting:: CELERY_SECURITY_CERT_STORE
  958. CELERY_SECURITY_CERT_STORE
  959. ~~~~~~~~~~~~~~~~~~~~~~~~~~
  960. .. versionadded:: 2.5
  961. The directory containing X.509 certificates used for
  962. :ref:`message-signing`. Can be a glob with wildcards,
  963. (for example :file:`/etc/certs/*.pem`).
  964. .. _conf-custom-components:
  965. Custom Component Classes (advanced)
  966. -----------------------------------
  967. .. setting:: CELERYD_BOOT_STEPS
  968. CELERYD_BOOT_STEPS
  969. ~~~~~~~~~~~~~~~~~~
  970. This setting enables you to add additional components to the worker process.
  971. It should be a list of module names with :class:`celery.abstract.Component`
  972. classes, that augments functionality in the worker.
  973. .. setting:: CELERYD_POOL
  974. CELERYD_POOL
  975. ~~~~~~~~~~~~
  976. Name of the pool class used by the worker.
  977. You can use a custom pool class name, or select one of
  978. the built-in aliases: ``processes``, ``eventlet``, ``gevent``.
  979. Default is ``processes``.
  980. .. setting:: CELERYD_POOL_RESTARTS
  981. CELERYD_POOL_RESTARTS
  982. ~~~~~~~~~~~~~~~~~~~~~
  983. If enabled the worker pool can be restarted using the
  984. :control:`pool_restart` remote control command.
  985. Disabled by default.
  986. .. setting:: CELERYD_AUTOSCALER
  987. CELERYD_AUTOSCALER
  988. ~~~~~~~~~~~~~~~~~~
  989. .. versionadded:: 2.2
  990. Name of the autoscaler class to use.
  991. Default is ``"celery.worker.autoscale.Autoscaler"``.
  992. .. setting:: CELERYD_AUTORELOADER
  993. CELERYD_AUTORELOADER
  994. ~~~~~~~~~~~~~~~~~~~~
  995. Name of the autoreloader class used by the worker to reload
  996. Python modules and files that have changed.
  997. Default is: ``"celery.worker.autoreload.Autoreloader"``.
  998. .. setting:: CELERYD_CONSUMER
  999. CELERYD_CONSUMER
  1000. ~~~~~~~~~~~~~~~~
  1001. Name of the consumer class used by the worker.
  1002. Default is :class:`celery.worker.consumer.Consumer`
  1003. .. setting:: CELERYD_MEDIATOR
  1004. CELERYD_MEDIATOR
  1005. ~~~~~~~~~~~~~~~~
  1006. Name of the mediator class used by the worker.
  1007. Default is :class:`celery.worker.controllers.Mediator`.
  1008. .. setting:: CELERYD_TIMER
  1009. CELERYD_TIMER
  1010. ~~~~~~~~~~~~~~~~~~~~~
  1011. Name of the ETA scheduler class used by the worker.
  1012. Default is :class:`celery.utils.timer2.Timer`, or one overrided
  1013. by the pool implementation.
  1014. .. _conf-celerybeat:
  1015. Periodic Task Server: celerybeat
  1016. --------------------------------
  1017. .. setting:: CELERYBEAT_SCHEDULE
  1018. CELERYBEAT_SCHEDULE
  1019. ~~~~~~~~~~~~~~~~~~~
  1020. The periodic task schedule used by :mod:`~celery.bin.celerybeat`.
  1021. See :ref:`beat-entries`.
  1022. .. setting:: CELERYBEAT_SCHEDULER
  1023. CELERYBEAT_SCHEDULER
  1024. ~~~~~~~~~~~~~~~~~~~~
  1025. The default scheduler class. Default is
  1026. `"celery.beat.PersistentScheduler"`.
  1027. Can also be set via the :option:`-S` argument to
  1028. :mod:`~celery.bin.celerybeat`.
  1029. .. setting:: CELERYBEAT_SCHEDULE_FILENAME
  1030. CELERYBEAT_SCHEDULE_FILENAME
  1031. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1032. Name of the file used by `PersistentScheduler` to store the last run times
  1033. of periodic tasks. Can be a relative or absolute path, but be aware that the
  1034. suffix `.db` may be appended to the file name (depending on Python version).
  1035. Can also be set via the :option:`--schedule` argument to
  1036. :mod:`~celery.bin.celerybeat`.
  1037. .. setting:: CELERYBEAT_MAX_LOOP_INTERVAL
  1038. CELERYBEAT_MAX_LOOP_INTERVAL
  1039. ~~~~~~~~~~~~~~~~~~~~~~~~~~~~
  1040. The maximum number of seconds :mod:`~celery.bin.celerybeat` can sleep
  1041. between checking the schedule.
  1042. The default for this value is scheduler specific.
  1043. For the default celerybeat scheduler the value is 300 (5 minutes),
  1044. but for e.g. the django-celery database scheduler it is 5 seconds
  1045. because the schedule may be changed externally, and so it must take
  1046. changes to the schedule into account.
  1047. Also when running celerybeat embedded (:option:`-B`) on Jython as a thread
  1048. the max interval is overridden and set to 1 so that it's possible
  1049. to shut down in a timely manner.
  1050. .. _conf-celerymon:
  1051. Monitor Server: celerymon
  1052. -------------------------
  1053. .. setting:: CELERYMON_LOG_FORMAT
  1054. CELERYMON_LOG_FORMAT
  1055. ~~~~~~~~~~~~~~~~~~~~
  1056. The format to use for log messages.
  1057. Default is `[%(asctime)s: %(levelname)s/%(processName)s] %(message)s`
  1058. See the Python :mod:`logging` module for more information about log
  1059. formats.