Skip to content

Commit a090f79

Browse files
committed
Updates daemonization tutorial for core Djngo support
1 parent 6ba9dfd commit a090f79

File tree

1 file changed

+28
-128
lines changed

1 file changed

+28
-128
lines changed

docs/tutorials/daemonizing.rst

Lines changed: 28 additions & 128 deletions
Original file line numberDiff line numberDiff line change
@@ -48,11 +48,12 @@ This is an example configuration for a Python project.
4848

4949
.. code-block:: bash
5050
51-
# Name of nodes to start
52-
# here we have a single node
53-
CELERYD_NODES="w1"
54-
# or we could have three nodes:
55-
#CELERYD_NODES="w1 w2 w3"
51+
# Names of nodes to start
52+
# most will only start one node:
53+
CELERYD_NODES="worker1"
54+
# but you can also start multiple and configure settings
55+
# for each in CELERYD_OPTS (see `celery multi --help` for examples).
56+
CELERYD_NODES="worker1 worker2 worker3"
5657
5758
# Absolute or relative path to the 'celery' command:
5859
CELERY_BIN="/usr/local/bin/celery"
@@ -75,80 +76,30 @@ This is an example configuration for a Python project.
7576
CELERYD_PID_FILE="/var/run/celery/%N.pid"
7677
7778
# Workers should run as an unprivileged user.
79+
# You need to create this user manually (or you can choose
80+
# a user/group combination that already exists, e.g. nobody).
7881
CELERYD_USER="celery"
7982
CELERYD_GROUP="celery"
8083
84+
# If enabled pid and log directories will be created if missing,
85+
# and owned by the userid/group configured.
86+
CELERY_CREATE_DIRS=1
87+
88+
8189
.. _generic-initd-celeryd-django-example:
8290

8391
Example Django configuration
8492
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
8593

86-
This is an example configuration for those using `django-celery`:
87-
88-
.. code-block:: bash
89-
90-
# Name of nodes to start, here we have a single node
91-
CELERYD_NODES="w1"
92-
# or we could have three nodes:
93-
#CELERYD_NODES="w1 w2 w3"
94-
95-
# Where to chdir at start.
96-
CELERYD_CHDIR="/opt/Myproject/"
97-
98-
# How to call "manage.py celery"
99-
CELERY_BIN="$CELERYD_CHDIR/manage.py celery"
100-
101-
# Extra command-line arguments for the worker (see celery worker --help).
102-
CELERYD_OPTS="--time-limit=300 --concurrency=8"
103-
104-
# %n will be replaced with the nodename.
105-
CELERYD_LOG_FILE="/var/log/celery/%n.log"
106-
CELERYD_PID_FILE="/var/run/celery/%n.pid"
107-
108-
# Workers should run as an unprivileged user.
109-
CELERYD_USER="celery"
110-
CELERYD_GROUP="celery"
111-
112-
# Name of the projects settings module.
113-
export DJANGO_SETTINGS_MODULE="MyProject.settings"
114-
115-
.. _generic-initd-celeryd-django-with-env-example:
116-
117-
Example Django configuration Using Virtualenv
118-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
119-
120-
In case you are using virtualenv, you should add the path to your
121-
environment's python interpreter:
94+
You should use the same template as above, but make sure the
95+
``DJANGO_SETTINGS_MODULE`` variable is set (and exported), and that
96+
``CELERYD_CHDIR`` is set to the projects directory:
12297

12398
.. code-block:: bash
12499
125-
# Name of nodes to start, here we start three nodes (worker1,
126-
# worker2, and worker3)
127-
CELERYD_NODES="worker1 worker2 worker3"
128-
129-
# Where to chdir at start.
130-
CELERYD_CHDIR="/opt/Myproject/"
131-
132-
# Python interpreter from environment.
133-
ENV_PYTHON="$CELERYD_CHDIR/env/bin/python"
134-
135-
# How to call "manage.py celery"
136-
CELERYD_MULTI="$CELERYD_CHDIR/env/bin/celeryd-multi"
137-
CELERY_BIN="$ENV_PYTHON $CELERYD_CHDIR/manage.py celery"
138-
139-
# Extra command-line arguments to the worker (see celery worker --help)
140-
CELERYD_OPTS="--time-limit=300 --concurrency=8"
141-
142-
# %n will be replaced with the nodename.
143-
CELERYD_LOG_FILE="/var/log/celery/%n.log"
144-
CELERYD_PID_FILE="/var/run/celery/%n.pid"
145-
146-
# Workers should run as an unprivileged user.
147-
CELERYD_USER="celery"
148-
CELERYD_GROUP="celery"
100+
export DJANGO_SETTINGS_MODULE="settings"
149101
150-
# Name of the projects settings module.
151-
export DJANGO_SETTINGS_MODULE="MyProject.settings"
102+
CELERYD_CHDIR="/opt/MyProject"
152103
153104
.. _generic-initd-celeryd-options:
154105

@@ -157,6 +108,8 @@ Available options
157108

158109
* CELERY_APP
159110
App instance to use (value for ``--app`` argument).
111+
If you're still using the old API, or django-celery, then you
112+
can omit this setting.
160113

161114
* CELERY_BIN
162115
Absolute or relative path to the :program:`celery` program.
@@ -167,19 +120,14 @@ Available options
167120
* :file:`/virtualenvs/proj/bin/celery`
168121
* :file:`/virtualenvs/proj/bin/python -m celery`
169122

170-
* CELERYD_MULTI
171-
Absolute or relative path to the program `celeryd-multi`, which is used to start multiple celeryd instances,
172-
Examples:
173-
174-
* :file:`celeryd-multi`
175-
* :file:`/virtualenvs/proj/bin/celeryd-multi`
176-
177123
* CELERYD_NODES
178-
Node names to start.
124+
List of node names to start (separated by space).
179125

180126
* CELERYD_OPTS
181127
Additional command-line arguments for the worker, see
182-
`celery worker --help` for a list.
128+
`celery worker --help` for a list. This also supports the extended
129+
syntax used by `multi` to configure settings for individual nodes.
130+
See `celery multi --help` for some multi-node configuration examples.
183131

184132
* CELERYD_CHDIR
185133
Path to change directory to at start. Default is to stay in the current
@@ -251,53 +199,15 @@ This is an example configuration for a Python project:
251199
Example Django configuration
252200
~~~~~~~~~~~~~~~~~~~~~~~~~~~~
253201

254-
This is an example configuration for those using `django-celery`
255-
256-
`/etc/default/celerybeat`:
202+
You should use the same template as above, but make sure the
203+
``DJANGO_SETTINGS_MODULE`` variable is set (and exported), and that
204+
``CELERYD_CHDIR`` is set to the projects directory:
257205

258206
.. code-block:: bash
259207
260-
# Where the Django project is.
261-
CELERYBEAT_CHDIR="/opt/Project/"
262-
263-
# Name of the projects settings module.
264208
export DJANGO_SETTINGS_MODULE="settings"
265209
266-
# Path to celery command
267-
CELERBEAT="/opt/Project/manage.py celery beat"
268-
269-
# Extra arguments to celerybeat
270-
CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"
271-
272-
# Overrider default log and/or PID file locations
273-
CELERYBEAT_LOG_FILE="/var/log/celerybeat.log"
274-
CELERYBEAT_PID_FILE="/var/run/celerybeat.pid"
275-
276-
.. _generic-initd-celerybeat-django-width-env-example:
277-
278-
Example Django configuration Using Virtualenv
279-
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
280-
281-
In case you are using virtualenv, you should add the path to your
282-
environment's python interpreter:
283-
284-
`/etc/default/celerybeat`:
285-
286-
.. code-block:: bash
287-
288-
# Where the Django project is.
289-
CELERYBEAT_CHDIR="/opt/Project"
290-
291-
# Name of the projects settings module.
292-
export DJANGO_SETTINGS_MODULE="settings"
293-
294-
# Path to celery command
295-
ENV_PYTHON="$CELERYD_CHDIR/env/bin/python"
296-
CELERYBEAT="$ENV_PYTHON $CELERYBEAT_CHDIR/manage.py celery beat"
297-
298-
# Extra arguments to celerybeat
299-
CELERYBEAT_OPTS="--schedule=/var/run/celerybeat-schedule"
300-
210+
CELERYD_CHDIR="/opt/MyProject"
301211
.. _generic-initd-celerybeat-options:
302212

303213
Available options
@@ -306,16 +216,6 @@ Available options
306216
* CELERY_APP
307217
App instance to use (value for ``--app`` argument).
308218

309-
* CELERYBEAT
310-
Absolute or relative path to the :program:`celery beat` program.
311-
Examples:
312-
313-
* :file:`celerybeat`
314-
* :file:`/usr/local/bin/celerybeat`
315-
* :file:`/virtualenvs/proj/bin/celerybeat`
316-
* :file:`/opt/Project/manage.py celery beat`
317-
* :file:`/virtualenvs/proj/bin/python -m celerybeat`
318-
319219
* CELERYBEAT_OPTS
320220
Additional arguments to celerybeat, see `celerybeat --help` for a
321221
list.

0 commit comments

Comments
 (0)