add unless-stopped restart policy, systemd user unit, readme

This commit is contained in:
Niko Marmeladkov 2026-07-03 11:01:59 +03:00
parent 653b8d1612
commit 74b9539149
Signed by untrusted user who does not match committer: Niko
GPG key ID: E3B955F9442D44E3
4 changed files with 32 additions and 1 deletions

View file

@ -46,6 +46,22 @@ Placeholders in `command` / `stop_command`: `{name}`, `{workdir}`, `{pid}`, `{lo
See `config.example.toml` for a full example.
## systemd (user mode)
```sh
mkdir -p ~/.config/systemd/user
cp contrib/rss.service ~/.config/systemd/user/
systemctl --user daemon-reload
systemctl --user enable rss
systemctl --user start rss
```
Requires `linger` for headless users:
```sh
sudo loginctl enable-linger $USER
```
## Install
```sh

13
contrib/rss.service Normal file
View file

@ -0,0 +1,13 @@
[Unit]
Description=RuSt Supervisor
After=network.target
[Service]
Type=simple
ExecStart=%h/.cargo/bin/rss daemon
Restart=on-failure
RestartSec=5
Environment=RSS_CONFIG=%h/.config/rss/config.toml
[Install]
WantedBy=default.target

View file

@ -55,6 +55,8 @@ fn default_stop_signal() -> String {
pub enum RestartPolicy {
No,
Always,
#[serde(alias = "unless-stopped")]
UnlessStopped,
OnFailure,
}

View file

@ -77,7 +77,7 @@ pub fn run_supervisor(name: &str, cfg: &ServiceConfig) {
let should_restart = match cfg.restart {
RestartPolicy::No => false,
RestartPolicy::Always => true,
RestartPolicy::Always | RestartPolicy::UnlessStopped => true,
RestartPolicy::OnFailure => !status.success(),
};