Sage
Docs / Concepts

Running as a service

Sage runs as a long-lived service. On most Linux systems that means a systemd unit.

systemd

Create a user for it and the unit:

$ sudo useradd --system --home /var/lib/sage --create-home --shell /usr/sbin/nologin sage
# /etc/systemd/system/sage.service
[Unit]
Description=Sage
After=network-online.target
Wants=network-online.target

[Service]
User=sage
ExecStart=/usr/local/bin/sage run
ExecReload=/bin/kill -HUP $MAINPID
Restart=on-failure
RestartSec=5
NoNewPrivileges=true
ProtectSystem=strict
ReadWritePaths=/var/lib/sage

[Install]
WantedBy=multi-user.target
$ sudo systemctl daemon-reload
$ sudo systemctl enable --now sage
$ journalctl -u sage -f

Sage reloads its configuration on SIGHUP, so systemctl reload sage applies changes without a restart.

Containers

Release archives include a Dockerfile. Build the image once and run it with the configuration mounted:

$ docker build -t sage:0.5.0 .
$ docker run -d --name sage --restart unless-stopped -v /etc/sage:/etc/sage:ro sage:0.5.0 run

Upgrading

Replace the binary and restart. Within a major version the configuration stays compatible; the changelog says when anything needs your attention.