From 2a72a6008f1d59a854248060f53f2025e4537d04 Mon Sep 17 00:00:00 2001 From: Joey Wilhelm Date: Thu, 3 May 2018 12:12:00 -0700 Subject: [PATCH 1/2] Add example files for using with systemd --- README.rst | 16 +++++++++++++++- extra/systemd/celerycam.conf | 13 +++++++++++++ extra/systemd/celerycam.service | 20 ++++++++++++++++++++ 3 files changed, 48 insertions(+), 1 deletion(-) create mode 100644 extra/systemd/celerycam.conf create mode 100644 extra/systemd/celerycam.service diff --git a/README.rst b/README.rst index f9e52394..3c4b0709 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/``, 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..9867dca5 --- /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 +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 From 71202d13f6f9d35292ed1e5361f981212f408eeb Mon Sep 17 00:00:00 2001 From: Joey Wilhelm Date: Mon, 2 Jul 2018 08:29:20 -0700 Subject: [PATCH 2/2] Fix the paths of the config file to jive with each other --- README.rst | 2 +- extra/systemd/celerycam.service | 2 +- 2 files changed, 2 insertions(+), 2 deletions(-) diff --git a/README.rst b/README.rst index 3c4b0709..8fbd5060 100644 --- a/README.rst +++ b/README.rst @@ -96,7 +96,7 @@ For a complete listing of the command-line options available see: 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/``, and ``celerycam.service`` under +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: diff --git a/extra/systemd/celerycam.service b/extra/systemd/celerycam.service index 9867dca5..327cc7c6 100644 --- a/extra/systemd/celerycam.service +++ b/extra/systemd/celerycam.service @@ -6,7 +6,7 @@ After=network.target Type=simple User=celery Group=celery -EnvironmentFile=/etc/sysconfig/celerycam +EnvironmentFile=/etc/sysconfig/celerycam.conf WorkingDirectory=/opt/celery ExecStart=/bin/sh -c '${CELERY_BIN} events -A ${CELERY_APP} \ --workdir=${CELERYCAM_CHDIR} \