|
|
|
[![Pipeline Status](https://gitlab.com/rascul/sup/badges/master/pipeline.svg)](https://gitlab.com/rascul/sup/pipelines)
|
|
|
|
[![MIT License](https://img.shields.io/badge/license-MIT-blue.svg)](https://gitlab.com/rascul/sup/blob/master/LICENSE)
|
|
|
|
|
|
|
|
Sup is a small process supervisor. It is originally to monitor some
|
|
|
|
applications in my X session but it can be used for other things.
|
|
|
|
|
|
|
|
## Installing
|
|
|
|
|
|
|
|
```shell
|
|
|
|
$ git clone https://gitlab.com/rascul/sup
|
|
|
|
$ cd sup
|
|
|
|
$ cargo install --path .
|
|
|
|
```
|
|
|
|
|
|
|
|
## Running
|
|
|
|
|
|
|
|
Sup must find the config file sup.toml in the current directory.
|
|
|
|
|
|
|
|
## Features
|
|
|
|
|
|
|
|
### Restart
|
|
|
|
|
|
|
|
Sup can be configured to restart an application when it stops. There are three
|
|
|
|
conditions sup can watch for:
|
|
|
|
|
|
|
|
* Success: In this case, the application has done a normal shutdown and the
|
|
|
|
exit status is 0.
|
|
|
|
* Failure: If the application exits with a non zero exit status it is
|
|
|
|
considered to have failed.
|
|
|
|
* Terminated: The application was killed by some other mechanism.
|
|
|
|
|
|
|
|
### Holds
|
|
|
|
|
|
|
|
A hold may be placed on any number of application. If there are any holds, sup
|
|
|
|
will keep track and while any held applications are running, sup will not exit.
|
|
|
|
When all held applications are no longer running, and are not configured to
|
|
|
|
restart anymore, sup will close the other applications and shutdown. If no holds
|
|
|
|
are specified, sup will start apps until it realizes there are no holds then
|
|
|
|
proceed to exit.
|
|
|
|
|
|
|
|
## Configuration File
|
|
|
|
|
|
|
|
The configuration file is sup.toml and will be found in the current directory
|
|
|
|
when starting sup. This will change in the future. Sup uses the
|
|
|
|
[toml](https://github.com/toml-lang/toml) format to describe each application
|
|
|
|
to supervise.
|
|
|
|
|
|
|
|
### `[[app]]`
|
|
|
|
|
|
|
|
Each application instance to monitor will have an `[[app]]` section. The apps
|
|
|
|
will be started in the order as read from the file.
|
|
|
|
|
|
|
|
#### Required Entries
|
|
|
|
|
|
|
|
* name: The name of the application.
|
|
|
|
* command: The command to run, including path if necessary.
|
|
|
|
* args: An array of arguments to pass with the command. May be an empty array.
|
|
|
|
|
|
|
|
#### Optional Entries
|
|
|
|
|
|
|
|
* restart_on_success: Restart the app if it exits successfully. (Default: false)
|
|
|
|
* restart_on_failure: Restart the app if it fails. (Default: false)
|
|
|
|
* restart_on_terminate: Restart the app if it is terminated. (Default: false)
|
|
|
|
* wait: Don't run the next app until this one is finished. (Default: false)
|
|
|
|
* hold: Don't exit sup until this app has finished. (Default: false)
|
|
|
|
|
|
|
|
### Example
|
|
|
|
|
|
|
|
```toml
|
|
|
|
[[app]]
|
|
|
|
name = "x resource"
|
|
|
|
command = "xrdb"
|
|
|
|
args = ["~/.Xresources"]
|
|
|
|
wait = true
|
|
|
|
|
|
|
|
[[app]]
|
|
|
|
name = "terminal"
|
|
|
|
command = "alacritty"
|
|
|
|
args = []
|
|
|
|
restart_on_success = false
|
|
|
|
restart_on_failure = true
|
|
|
|
restart_on_terminate = true
|
|
|
|
hold = true
|
|
|
|
|
|
|
|
[[app]]
|
|
|
|
name = "environment"
|
|
|
|
command = "alacritty"
|
|
|
|
args = ["-e", "env"]
|
|
|
|
|
|
|
|
[[app]]
|
|
|
|
name = "window manager"
|
|
|
|
command = "twm"
|
|
|
|
args = []
|
|
|
|
hold = true
|
|
|
|
```
|