https://github.com/cdaringe/swaperooni
Hot swap a child process in response to user provided events with signal proxying
https://github.com/cdaringe/swaperooni
docker hot-reload init init-system
Last synced: 8 months ago
JSON representation
Hot swap a child process in response to user provided events with signal proxying
- Host: GitHub
- URL: https://github.com/cdaringe/swaperooni
- Owner: cdaringe
- Created: 2023-12-31T04:16:10.000Z (about 2 years ago)
- Default Branch: main
- Last Pushed: 2024-08-01T03:22:01.000Z (over 1 year ago)
- Last Synced: 2024-10-31T07:48:27.083Z (over 1 year ago)
- Topics: docker, hot-reload, init, init-system
- Language: Rust
- Homepage:
- Size: 1.09 MB
- Stars: 2
- Watchers: 3
- Forks: 0
- Open Issues: 1
-
Metadata Files:
- Readme: readme.md
Awesome Lists containing this project
README
# swaperooni
Hot-reload a child process without tearing down the parent PID. Proxies signals
into the child process.

[](https://github.com/cdaringe/swaperooni/actions/workflows/rust.yml)
- if the child exits, `swaperooni` exits with the same code.
- if a swap request is issued, the child is torn down, and new child brought up.
Supports two hot-reload request options:
- `ipc` - send a newline delimited command string from the child to the swaperooni socket. See [examples/ipc_bash_hopscotch/main.sh](examples/ipc_bash_hopscotch/main.sh).
- `poll` - monitor the `mtime` of a file. on change, re-execute it.
**swaperooni is not a supervisor.** `swaperooni` is similar to [tini](https://github.com/krallin/tini).
## Why
Because you can. Generally, avoid using this, and use a supervisor/orchestrator.
You may have cases where swapping child PIDs is more desirable (e.g. oddball docker/k8s environments).
## How
See the examples.
- `SOCKET_PATH=demo.sock cargo run ipc -- bash examples/ipc_bash_hopscotch/a.sh`
- program `a` runs momentarily, then requests to be swapped for program `b`. `b` requests program `c`, and `c` gracefully exits.
- `SOCKET_PATH=demo.sock cargo run ipc -- node examples/ipc_node_counter/index.mjs 0`
- run a node.js process. the process asks swaperooni to run itself again, but with different params (a counter)
- `cargo run poll --poll-interval-ms=1000 -- examples/poll_countdown/main.sh 5`
- poll for entrypoint change and re-run it.
## Performance
Well, it is <1MB and does nothing _most_ of the time.