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

2 KiB

+++ title = "Service Managers (eg. systemd)" weight = 40 +++

You may want to start Aerogramme on boot.

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:

[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:

sudo systemctl start aerogramme
sudo systemctl enable aerogramme

To see if the service is running and to browse its logs:

sudo systemctl status aerogramme
sudo journalctl -u aerogramme

To add a new user:

sudo aerogramme \
  -c /etc/aerogramme/config.toml \
  provider account add --login alice --setup #...

sudo systemctl reload aerogramme

docker-compose

An example docker compose deployment with Garage included:

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