diff --git a/README.rst b/README.rst index f9e52394..8fbd5060 100644 --- a/README.rst +++ b/README.rst @@ -94,6 +94,21 @@ For a complete listing of the command-line options available see: $ celery events --help +If you would like to use ``systemd`` to run the process, there are example +configuration files available under the ``extra/systemd/`` folder. After placing +the ``celerycam.conf`` under ``/etc/sysconfig/``, and ``celerycam.service`` under +``/etc/systemd/system/``, you will be able to use the ``systemctl`` command to +control the daemon. For example: + +.. code-block:: console + + $ systemctl start celerycam + +.. code-block:: console + + $ systemctl stop celerycam + + Configuration ============= @@ -147,4 +162,3 @@ In your Celery configuration simply set them to override the defaults, e.g.:: .. |pyimp| image:: https://img.shields.io/pypi/implementation/django-celery-monitor.svg :alt: Support Python implementations. :target: http://pypi.python.org/pypi/django_celery_monitor/ - diff --git a/extra/systemd/celerycam.conf b/extra/systemd/celerycam.conf new file mode 100644 index 00000000..2a9499f7 --- /dev/null +++ b/extra/systemd/celerycam.conf @@ -0,0 +1,13 @@ +# Absolute or relative path to the 'celery' command: +CELERY_BIN="/usr/bin/celery" +CELERY_APP="proj" + +# Where to chdir at start. +CELERYCAM_CHDIR="/opt/celery" + +# Extra arguments to celerycam +CELERYCAM_OPTS="--camera django_celery_monitor.camera.Camera --frequency=2.0" + +CELERYCAM_LOG_FILE="/var/log/celery/celerycam.log" +CELERYCAM_PID_FILE="/var/run/celery/celery_cam.pid" +CELERYCAM_LOG_LEVEL="INFO" diff --git a/extra/systemd/celerycam.service b/extra/systemd/celerycam.service new file mode 100644 index 00000000..327cc7c6 --- /dev/null +++ b/extra/systemd/celerycam.service @@ -0,0 +1,20 @@ +[Unit] +Description=Celery Camera Service +After=network.target + +[Service] +Type=simple +User=celery +Group=celery +EnvironmentFile=/etc/sysconfig/celerycam.conf +WorkingDirectory=/opt/celery +ExecStart=/bin/sh -c '${CELERY_BIN} events -A ${CELERY_APP} \ + --workdir=${CELERYCAM_CHDIR} \ + --pidfile=${CELERYCAM_PID_FILE} \ + --logfile=${CELERYCAM_LOG_FILE} \ + --loglevel=${CELERYCAM_LOG_LEVEL} \ + ${CELERYCAM_OPTS}' +ExecStop=/bin/systemctl kill celerycam.service + +[Install] +WantedBy=multi-user.target