Skip to content

Commit

Permalink
Cleanup systemd unit file. (#24)
Browse files Browse the repository at this point in the history
Bea suggested some changes <3
  • Loading branch information
Gnuxie authored Jul 1, 2024
1 parent cdcc3d1 commit 6fecc41
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 10 deletions.
4 changes: 2 additions & 2 deletions docs/bot/setup.md
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@ See the following links for corresponding installation documentation:
the most convenient way to run Matrix services. Recommended if you
are preparing a new homeserver or are already using
matrix-docker-ansible-deploy.
- [Advanced Docker setup](./setup_docker.md) - for experianced system
- [Advanced Docker setup](./setup_docker.md) - for experienced system
administrators.
- [Advanced setup from source](./setup_selfbuild.md) - for experianced
- [Advanced setup from source](./setup_selfbuild.md) - for experienced
system administrators.
4 changes: 2 additions & 2 deletions docs/bot/setup_docker.md
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@ sidebar_label: Advanced Docker setup

:::tip

This guide is for experianced system administrators. If you are
This guide is for experienced system administrators. If you are
unfamiliar with Docker or system administration in general,
then you should refer to our recommended installation method
of [using Docker with systemd](./systemd).
Expand Down Expand Up @@ -72,7 +72,7 @@ Arguments to Draupnir itself from `docker run` begin with `bot`.

:::

The container entrypoint is shared with the option to deploy Draupnir
The container entry-point is shared with the option to deploy Draupnir
as an appservice, and therefore *bot mode* must be explicitly asked
for when providing options with `docker run`. This is done by ensuring
the first argument that gets passed to the container is `bot`.
Expand Down
23 changes: 17 additions & 6 deletions docs/bot/systemd.md
Original file line number Diff line number Diff line change
Expand Up @@ -32,22 +32,33 @@ Description=Draupnir Docker Container
After=docker.service
Requires=docker.service
After=network-online.target
Wants=network-online.target
[Service]
Type=simple
ExecStartPre=-/usr/bin/env sh -c '/usr/bin/env docker stop --time=3 draupnir 2>/dev/null || true'
ExecStartPre=-/usr/bin/env sh -c '/usr/bin/env docker rm draupnir 2>/dev/null || true'
Type=exec
# Update Draupnir
ExecStartPre=docker image pull gnuxie/draupnir:latest
# Clean up any accidentally existing containers
ExecStartPre=docker container rm --force draupnir
ExecStart=docker container run --rm --pull=never --name=draupnir -v /var/lib/draupnir:/data gnuxie/draupnir:latest bot --draupnir-config /data/config/production.yaml
ExecStart=/usr/bin/docker run --rm --pull=always --name=draupnir -v /var/lib/draupnir:/data gnuxie/draupnir:latest bot --draupnir-config /data/config/production.yaml
ExecStop=-docker container stop --time=10 draupnir
ExecStop=-/usr/bin/env sh -c '/usr/bin/env docker stop --time=3 draupnir 2>/dev/null || true'
ExecStop=-/usr/bin/env sh -c '/usr/bin/env docker rm draupnir 2>/dev/null || true'
# Let Docker handle timeout instead
TimeoutStopSec=infinity
Restart=always
RestartSec=30
[Install]
WantedBy=multi-user.target
```

You will then need to run `systemctl daemon-reload` to register the
service file.

Finally run `systemctl enable draupnir.service` to tell systemd to
start Draupnir the next time your system boots.

Expand Down

0 comments on commit 6fecc41

Please sign in to comment.