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/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