From 2277ea3ac1062c99341bc9711e4171f1a25e9565 Mon Sep 17 00:00:00 2001 From: "Joshua M. Boniface" Date: Sun, 31 Oct 2021 00:51:38 -0400 Subject: [PATCH] Add systemd example configurations --- systemd/README.md | 21 +++++++++++++++++++++ systemd/bbuilder-api.service | 13 +++++++++++++ systemd/bbuilder-worker.service | 13 +++++++++++++ systemd/environment.example | 8 ++++++++ 4 files changed, 55 insertions(+) create mode 100644 systemd/README.md create mode 100644 systemd/bbuilder-api.service create mode 100644 systemd/bbuilder-worker.service create mode 100644 systemd/environment.example diff --git a/systemd/README.md b/systemd/README.md new file mode 100644 index 0000000..37257af --- /dev/null +++ b/systemd/README.md @@ -0,0 +1,21 @@ +# Example Systemd configuration for Basic Builder + +This directory contains an example configuration set for running Basic Builder under systemd. + +This presumes you've done a `pip3 install .` in the root of the repository (or in a virtualenv, etc.). + +For demonstration purposes, the `ExecStart` path is `/usr/local/bin/bbuilder`, the `EnvironmentFile` is located at `/etc/default/bbuilder`, and that the `User` to execute as is named `git`. + +1. Copy `environment.example` to `/etc/default/bbuilder` and edit it to suit your needs. + + **NOTE:** This file contains the sensitive `BB_AUTH_KEY` value. Ensure this file is only readable by trusted users (e.g. mode `400`)! + +1. Copy `bbuilder-api.service` and `bbuilder-worker.service` into `/etc/systemd/system`. + +1. Run `sudo systemctl daemon-reload` to load the changes to Systemd. + +1. If applicable, create your service user. + +1. Start the API (`sudo systemctl start bbuilder-api.service`) and Worker (`sudo systemctl start bbuilder-worker.service`). + +1. Configure your webhooks, etc. diff --git a/systemd/bbuilder-api.service b/systemd/bbuilder-api.service new file mode 100644 index 0000000..97b6479 --- /dev/null +++ b/systemd/bbuilder-api.service @@ -0,0 +1,13 @@ +[Unit] +Description=Basic Builder API +After=network-online.target redis.service + +[Service] +Type=simple +User=git +EnvironmentFile = /etc/default/bbuilder +ExecStart=/usr/local/bin/bbuilder run +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/systemd/bbuilder-worker.service b/systemd/bbuilder-worker.service new file mode 100644 index 0000000..82a6e0a --- /dev/null +++ b/systemd/bbuilder-worker.service @@ -0,0 +1,13 @@ +[Unit] +Description=Basic Builder API +After=network-online.target redis.service + +[Service] +Type=simple +User=git +EnvironmentFile = /etc/default/bbuilder +ExecStart=/usr/local/bin/bbuilder worker +Restart=on-failure + +[Install] +WantedBy=multi-user.target diff --git a/systemd/environment.example b/systemd/environment.example new file mode 100644 index 0000000..93d79a8 --- /dev/null +++ b/systemd/environment.example @@ -0,0 +1,8 @@ +PYTHONUNBUFFERED="true" +BB_BROKER="redis://127.0.0.1:6379/0" +BB_WORK_DIR="/tmp/bbuilder" +BB_DEBUG="false" +BB_LISTEN_ADDR="0.0.0.0" +BB_LISTEN_PORT="7999" +BB_AUTH_KEY="I'mALittleTeapot" +BB_CONCURRENCY=1