configuration.rst 41 KB

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