configuration.rst 42 KB

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