Skip to content

Commit

Permalink
Add example files for using with systemd
Browse files Browse the repository at this point in the history
  • Loading branch information
jwilhelm-godaddy committed May 3, 2018
1 parent 1f890c9 commit 2a72a60
Show file tree
Hide file tree
Showing 3 changed files with 48 additions and 1 deletion.
16 changes: 15 additions & 1 deletion README.rst
Original file line number Diff line number Diff line change
Expand Up @@ -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
=============

Expand Down Expand Up @@ -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/

13 changes: 13 additions & 0 deletions extra/systemd/celerycam.conf
Original file line number Diff line number Diff line change
@@ -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"
20 changes: 20 additions & 0 deletions extra/systemd/celerycam.service
Original file line number Diff line number Diff line change
@@ -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

0 comments on commit 2a72a60

Please sign in to comment.