From 9f03a3d42c2a0debb0638567373ffb530dff7694 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Aur=C3=A9lien=20Bompard?= Date: Tue, 29 Jan 2019 14:20:16 +0100 Subject: [PATCH] Add a consumer systemd service file MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Signed-off-by: Aurélien Bompard --- docs/fedora-messaging.rst | 20 ++++++++++++++++++++ fm-consumer@.service | 11 +++++++++++ 2 files changed, 31 insertions(+) create mode 100644 fm-consumer@.service diff --git a/docs/fedora-messaging.rst b/docs/fedora-messaging.rst index a9c8827c..152812bb 100644 --- a/docs/fedora-messaging.rst +++ b/docs/fedora-messaging.rst @@ -95,6 +95,26 @@ configuration file and no options on the command line. in *all* ``bindings`` entries in the configuration file. +Systemd service +=============== + +The ``consume`` subcommand can be started as a system service, and Fedora +Messaging provides a dynamic systemd service file. + +First, create a valid Fedora Messaging configuration file in +``/etc/fedora-messaging/foo.toml``, with the ``callback`` parameter pointing to +your consuming function or class. Remember that you can use the +``consumer_config`` section for your own configuration. + +Enable and start the service in systemd with the following commands:: + + systemctl enable fm-consumer@foo.service + systemctl start fm-consumer@foo.service + +The service name after the ``@`` and before the ``.service`` must match your +filename in ``/etc/fedora-messaging`` (without the ``.toml`` suffix). + + Help ==== diff --git a/fm-consumer@.service b/fm-consumer@.service new file mode 100644 index 00000000..d6c13bc4 --- /dev/null +++ b/fm-consumer@.service @@ -0,0 +1,11 @@ +[Unit] +Description=Fedora Messaging consumer +Documentation=http://fedora-messaging.readthedocs.io/ + +[Service] +Type=simple +ExecStart=fedora-messaging --conf /etc/fedora-messaging/%i.toml consume +Restart=on-failure + +[Install] +WantedBy=multi-user.target