Skip to content

Commit 88c5800

Browse files
committed
docs: add README for deadmanswitch
1 parent 6a85993 commit 88c5800

File tree

1 file changed

+34
-0
lines changed

1 file changed

+34
-0
lines changed

deadmanswitch/README.md

Lines changed: 34 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,34 @@
1+
# DeadManSwitch
2+
3+
DeadManSwitch is a lightweight Go program that runs a specified command with arguments and simultaneously starts a WebSocket signaling server.
4+
5+
## Program Behavior
6+
7+
DeadManSwitch operates with the following behavior:
8+
9+
1. If the launched command exits, DeadManSwitch exits as well.
10+
2. If no client connects to the WebSocket signaling server within `DEADMANSWITCH_TIMEOUT` seconds (default is 10 seconds), the process terminates.
11+
3. If a client connects but then disconnects, the process terminates.
12+
13+
## Configuration
14+
15+
You can configure DeadManSwitch using the following environment variables:
16+
17+
- **`DEADMANSWITCH_TIMEOUT`**: Sets the timeout (in seconds) to wait for clients to connect to the WebSocket signaling server. Default is 10 seconds.
18+
- **`DEADMANSWITCH_PORT`**: Specifies the port to run the server on.
19+
- **`DEADMANSWITCH_SUFFIX`**: Defines a suffix for the WebSocket URL endpoint.
20+
21+
## Usage Example
22+
23+
The following command launches `sleep 100` and accepts WebSocket connections on `ws://localhost:54321/foobar`:
24+
25+
```bash
26+
DEADMANSWITCH_TIMEOUT=10 \
27+
DEADMANSWITCH_PORT=54321 \
28+
DEADMANSWITCH_SUFFIX=foobar \
29+
deadmanswitch sleep 100
30+
```
31+
32+
## Compilation
33+
34+
To compile, run `./build.sh`

0 commit comments

Comments
 (0)