Jelajahi Sumber

Add in tutorial

Anarchist666 12 tahun lalu
induk
melakukan
be2690c225
2 mengubah file dengan 37 tambahan dan 5 penghapusan
  1. 34 2
      docs/tutorials/daemonizing.rst
  2. 3 3
      extra/systemd/celery.service

+ 34 - 2
docs/tutorials/daemonizing.rst

@@ -312,7 +312,7 @@ Available options
 .. _daemon-systemd-generic:
 
 Usage systemd
-====================
+=============
 
 .. _generic-systemd-celery:
 
@@ -324,7 +324,8 @@ Service file: celery.service
 
 To create a temporary folders for the log and pid files change user and group in 
 /usr/lib/tmpfiles.d/celery.conf.
-Setting WorkingDirectory in /usr/lib/systemd/system/celery.service defines chdir.
+To configure user, group, chdir change settings User, Group and WorkingDirectory defines 
+in /usr/lib/systemd/system/celery.service. 
 
 .. _generic-systemd-celery-example:
 
@@ -346,6 +347,37 @@ This is an example configuration for a Python project:
     # Absolute or relative path to the 'celery' command:
     CELERY_BIN="/usr/local/bin/celery"
     #CELERY_BIN="/virtualenvs/def/bin/celery"
+    
+    # How to call manage.py
+    CELERYD_MULTI="multi"
+
+    # Extra command-line arguments to the worker
+    CELERYD_OPTS="--time-limit=300 --concurrency=8"
+
+    # %N will be replaced with the first part of the nodename.
+    CELERYD_LOG_FILE="/var/log/celery/%N.log"
+    CELERYD_PID_FILE="/var/run/celery/%N.pid"
+
+.. _generic-systemd-celeryd-django-example:
+
+Example Django configuration
+~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+
+This is an example configuration for those using `django-celery`:
+
+.. code-block:: bash
+
+    # Name of nodes to start
+    # here we have a single node
+    CELERYD_NODES="w1"
+    # or we could have three nodes:
+    #CELERYD_NODES="w1 w2 w3"
+
+    # Absolute path to "manage.py"
+    CELERY_BIN="/opt/Myproject/manage.py"
+    
+    # How to call manage.py
+    CELERYD_MULTI="celery multi"
 
     # Extra command-line arguments to the worker
     CELERYD_OPTS="--time-limit=300 --concurrency=8"

+ 3 - 3
extra/systemd/celery.service

@@ -8,9 +8,9 @@ User=user
 Group=users
 EnvironmentFile=-/etc/conf.d/celery
 WorkingDirectory=/opt/Myproject/
-ExecStart=/usr/bin/python2 ${CELERY_BIN}/manage.py celeryd_multi start $CELERYD_NODES --pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} --loglevel="INFO" $CELERYD_OPTS 
-ExecStop=/usr/bin/python2 ${CELERY_BIN}/manage.py celeryd_multi stopwait $CELERYD_NODES --pidfile=${CELERYD_PID_FILE}
-ExecReload=/usr/bin/python2 ${CELERY_BIN}/manage.py celeryd_multi restart $CELERYD_NODES --pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} --loglevel="INFO" $CELERYD_OPTS 
+ExecStart=/usr/bin/python2 ${CELERY_BIN} $CELERYD_MULTI start $CELERYD_NODES --pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} --loglevel="INFO" $CELERYD_OPTS
+ExecStop=/usr/bin/python2 ${CELERY_BIN} $CELERYD_MULTI stopwait $CELERYD_NODES --pidfile=${CELERYD_PID_FILE}
+ExecReload=/usr/bin/python2 ${CELERY_BIN} $CELERYD_MULTI restart $CELERYD_NODES --pidfile=${CELERYD_PID_FILE} --logfile=${CELERYD_LOG_FILE} --loglevel="INFO" $CELERYD_OPTS
 
 [Install]
 WantedBy=multi-user.target