aerogramme.deuxfleurs.fr/content/documentation/cookbook/service-manager.md

98 lines
2.4 KiB
Markdown
Raw Normal View History

2024-01-22 10:01:47 +00:00
+++
title = "Service Managers (eg. systemd)"
weight = 40
+++
2024-01-23 19:21:03 +00:00
You may want to start Aerogramme automatically on boot,
restart it if it crashes, etc. Such actions can be achieved through a service manager.
2024-01-23 11:08:50 +00:00
## systemd
We make some assumptions for this systemd deployment.
- Your garage binary is located at `/usr/local/bin/aerogramme`.
- Your configuration file is located at `/etc/aerogramme/config.toml`.
- If you use Aerogramme's user management, the user list is set to `/etc/aerogramme/users.toml`.
Create a file named `/etc/systemd/system/aerogramme.service`:
```ini
[Unit]
Description=Aerogramme Email Server
After=network-online.target
Wants=network-online.target
[Service]
Environment='RUST_LOG=aerogramme=info' 'RUST_BACKTRACE=1'
ExecStart=/usr/local/bin/aerogramme -c /etc/aerogramme/config.toml provider daemon
DynamicUser=true
ProtectHome=true
NoNewPrivileges=true
[Install]
WantedBy=multi-user.target
```
**A note on hardening:** The Aerogramme daemon is not expected to write on the filesystem.
When you use the `aerogramme provider account`, the write is done by your current user/process,
not the daemon process. That's why we don't define a `StateDirectory`.
To start the service then automatically enable it at boot:
```bash
sudo systemctl start aerogramme
sudo systemctl enable aerogramme
```
To see if the service is running and to browse its logs:
```bash
sudo systemctl status aerogramme
sudo journalctl -u aerogramme
```
To add a new user:
```bash
sudo aerogramme \
-c /etc/aerogramme/config.toml \
provider account add --login alice --setup #...
sudo systemctl reload aerogramme
```
2024-01-23 19:21:03 +00:00
## Other service managers
Other service managers exists: SMF (illumos / solaris), OpenRC (alpine & co), rc (FreeBSD, OpenBSD, NetBSD).
Feel free to open a PR to add some documentation.
You would not use System V initialization scripts...
<!--
2024-01-23 11:08:50 +00:00
## docker-compose
An example docker compose deployment with Garage included:
```yml
version: "3"
services:
aerogramme:
image: registry.deuxfleurs.org/aerogramme:0.2.0
restart: unless-stopped
ports:
- "1025:1025"
- "143:1143"
volumes:
- aerogramme.toml:/aerogramme.toml
- users.toml:/users.toml
garage:
image: docker.io/dxflrs/garage:v0.9.1
restart: unless-stopped
volumes:
- garage.toml:/etc/garage.toml
- garage-meta:/var/lib/garage/meta
- garage-data:/var/lib/garage/data
```
2024-01-23 19:21:03 +00:00
-->