2.4 KiB
+++ title = "Service Managers (eg. systemd)" weight = 40 +++
You may want to start Aerogramme automatically on boot, restart it if it crashes, etc. Such actions can be achieved through a service manager.
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
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...