add unless-stopped restart policy, systemd user unit, readme
This commit is contained in:
parent
653b8d1612
commit
74b9539149
4 changed files with 32 additions and 1 deletions
16
README.md
16
README.md
|
|
@ -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
13
contrib/rss.service
Normal 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
|
||||
|
|
@ -55,6 +55,8 @@ fn default_stop_signal() -> String {
|
|||
pub enum RestartPolicy {
|
||||
No,
|
||||
Always,
|
||||
#[serde(alias = "unless-stopped")]
|
||||
UnlessStopped,
|
||||
OnFailure,
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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(),
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue