10 releases
0.4.0 | Aug 10, 2024 |
---|---|
0.3.3 | Aug 10, 2024 |
0.3.2 | Jun 19, 2023 |
0.2.4 | Mar 22, 2023 |
0.1.1 | Mar 19, 2023 |
#237 in Unix APIs
490 downloads per month
23KB
602 lines
Process Control
This is a simple process management tool. It runs processes as an interdependent graph.
You can think of Process Control as being like Docker Compose but for commands instead of containers. Or like Foreman but with support for process dependencies and availability checks.
(Process Control only works on Unix/Linux systems. It is tested on Linux and macOS.)
Installing
Install Process Control by downloading a release binary, or by using Homebrew on macOS:
$ brew install bww/stable/psctl
If you have a Rust toolchain installed, you can also install from crates.io:
$ cargo install psctl
How to use this thing
Processes can have availability checks associated with them, which are used to determine when it has finished starting up and has become available. Processes can also describe which other processes are their dependencies. Using all this information, Process Control will:
- Determine the order processes should be run,
- Execute each process in this order, in turn,
- Wait for each process to become available, if availability checks are provided, and then
- Wait forever for any process to exit.
Once any process exits, Process Control kills the other running processes and exits with the same exit code as the first exiting process.
The following process configuration file is illustrative:
version: 1
tasks:
-
name: a
run: sleep 3 && echo "A"
checks:
- https://hub.dummyapis.com/delay?seconds=2
- https://hub.dummyapis.com/delay?seconds=3
deps:
- b
- c
-
name: b
run: sleep 10 && echo "B"
checks:
- https://hub.dummyapis.com/delay?seconds=2
-
name: c
run: sleep 10 && echo "C"
checks:
- https://hub.dummyapis.com/delay?seconds=2
deps:
- b
It can be run as follows:
$ psctl --file test/example.yaml
====> b, c, a
----> b: sleep 10 && echo "B" (https://hub.dummyapis.com/delay?seconds=2)
----> c: sleep 10 && echo "C" (https://hub.dummyapis.com/delay?seconds=2)
----> a: sleep 3 && echo "A" (https://hub.dummyapis.com/delay?seconds=2; https://hub.dummyapis.com/delay?seconds=3)
A
====> finished
Notice that processes b
and c
are killed after a
exits normally, so they never echo anything.
Dependencies
~10–22MB
~320K SLoC