From 9815f00e789b52d558193b90a6857bfbdb62fd5f Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Alexis=20M=C3=A9taireau?= Date: Thu, 23 Nov 2023 17:15:13 +0100 Subject: [PATCH] Put systemd configuration files in the docs. Fix #3 --- conf/systemd-agent.service | 21 +++++++++++++++++++++ conf/systemd-server.service | 16 ++++++++++++++++ docs/cli.md | 8 ++++---- docs/deployment/systemd.md | 25 +++++++++++++++++++++++++ docs/index.md | 9 ++++++++- docs/installation/getting-started.md | 2 +- 6 files changed, 75 insertions(+), 6 deletions(-) create mode 100644 conf/systemd-agent.service create mode 100644 conf/systemd-server.service create mode 100644 docs/deployment/systemd.md diff --git a/conf/systemd-agent.service b/conf/systemd-agent.service new file mode 100644 index 0000000..fdadc28 --- /dev/null +++ b/conf/systemd-agent.service @@ -0,0 +1,21 @@ +[Unit] +Description=Argos agent +Documentation=https://framasoft.frama.io/framaspace/argos/ +Requires=network.target +After=network.target + +[Service] +User=www-data +Environment="ARGOS_AGENT_TOKEN=Secret" +Environment="ARGOS_AGENT_SERVER_URL=http://127.0.0.1:8000" +WorkingDirectory=/var/www/argos/ +ExecStart=/var/www/argos/venv/bin/argos agent --max-tasks 20 --wait-time 10 --log-level DEBUG +SyslogIdentifier=argos-agent + +[Install] +WantedBy=multi-user.target + +# NB: it may be better to +# - use a dedicated user +# - use a EnvironmentFile=/etc/default/argos-agent in order enable configuration +# changes without doing a systemctl daemon-reload \ No newline at end of file diff --git a/conf/systemd-server.service b/conf/systemd-server.service new file mode 100644 index 0000000..698e637 --- /dev/null +++ b/conf/systemd-server.service @@ -0,0 +1,16 @@ +[Unit] +Description=Argos server +Documentation=https://framasoft.frama.io/framaspace/argos/ +Requires=network.target postgresql.service +After=network.target postgresql.service +PartOf=postgresql.service + +[Service] +User=www-data +WorkingDirectory=/var/www/argos/ +ExecStart=/var/www/argos/venv/bin/argos server start +ExecReload=/var/www/argos/venv/bin/argos server reload +SyslogIdentifier=argos-server + +[Install] +WantedBy=multi-user.target diff --git a/docs/cli.md b/docs/cli.md index 5427c9c..453797f 100644 --- a/docs/cli.md +++ b/docs/cli.md @@ -75,8 +75,8 @@ Options: --help Show this message and exit. Commands: - clean Clean the database (to run routinely) - start Starts the server. + cleandb Clean the database (to run routinely) + start Starts the server. ``` ```man -Usage: argos server clean [OPTIONS] +Usage: argos server cleandb [OPTIONS] Clean the database (to run routinely) @@ -119,7 +119,7 @@ Usage: argos server clean [OPTIONS] been locked for too long. Options: - --max-results INTEGER Maximum number of results to keep + --max-results INTEGER Number of results per tasks to keep --max-lock-seconds INTEGER The number of seconds after which a lock is considered stale --help Show this message and exit. diff --git a/docs/deployment/systemd.md b/docs/deployment/systemd.md new file mode 100644 index 0000000..3a2e582 --- /dev/null +++ b/docs/deployment/systemd.md @@ -0,0 +1,25 @@ +# Using systemd + +Here are the systemd files that can be used to deploy the server and the agents. + +## Agent + +```{literalinclude} ../../conf/systemd-agent.service +--- +caption: /etc/systemd/system/argos-agent.service +--- +``` + +## Server + +```{literalinclude} ../../conf/systemd-server.service +--- +caption: /etc/systemd/system/argos-server.service +--- +``` + +Please note that it might be better to use Gunicorn with a Uvicorn worker, [as specified in the Uvicorn docs](https://www.uvicorn.org/#running-with-gunicorn): + +```bash +gunicorn example:app -w 4 -k uvicorn.workers.UvicornWorker +``` \ No newline at end of file diff --git a/docs/index.md b/docs/index.md index 459bba4..e26a56b 100644 --- a/docs/index.md +++ b/docs/index.md @@ -64,5 +64,12 @@ checks developer/overview developer/new-check developer/models - +changelog ``` + +```{toctree} +:caption: Deployment +:hidden: +deployment/systemd +``` + diff --git a/docs/installation/getting-started.md b/docs/installation/getting-started.md index e14701a..5f4693b 100644 --- a/docs/installation/getting-started.md +++ b/docs/installation/getting-started.md @@ -23,7 +23,7 @@ The quickest way to get started is to copy the `config-example.yaml` file and ed cp config-example.yaml config.yaml ``` -You can read more about the configuration in the [configuration section](configuration.md). +You can read more about the configuration in the [configuration section](../configuration.md). ## Starting the server