Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1,128 changes: 1,114 additions & 14 deletions Cargo.lock

Large diffs are not rendered by default.

59 changes: 49 additions & 10 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ Each task can have the following properties:
- `require` (optional): List of tasks that must be started before this one
- `autorestart` (optional): If true, automatically restart the task when it exits (default: false)
- `timestamps` (optional): If true, show timestamps for log messages (default: false)
- `healthcheck` (optional): Healthcheck configuration for the task (see below)

### Actions: `run` vs `ensure`

Expand All @@ -92,6 +93,38 @@ Each task can have the following properties:

These are mutually exclusive - a task can only have one or the other.

### Healthchecks

Tasks with a `run` action can optionally specify a healthcheck. When a healthcheck is configured, dependent tasks will wait for the healthcheck to pass before starting (similar to how `ensure` tasks block dependents until complete).

```yaml
tasks:
postgres:
run: docker run --rm -p 5432:5432 postgres
healthcheck:
tool: is-port-open 5432
interval: 1

api:
run: ./server
require: [postgres] # Won't start until postgres healthcheck passes
```

Healthcheck fields:
- `cmd`: A shell command to run. Healthcheck passes when it exits with code 0.
- `tool`: A built-in tool to run directly (without spawning a process). See below for available tools.
- `interval`: How often to run the healthcheck, in seconds (supports decimals like `0.5`).

You must specify either `cmd` or `tool`, but not both.

#### Built-in Healthcheck Tools

- `is-port-open <port>`: Check if a TCP port is open on localhost.
- `http-get <port or URL>`: Perform an HTTP GET request. If given a port number, hits `http://127.0.0.1:{port}/`. If given a full URL (starting with `http://` or `https://`), uses that URL directly. Passes if the server responds (any status code).
- `http-get-ok <port or URL>`: Same as `http-get`, but only passes if the server returns a 2xx status code.

Using `tool` is equivalent to `cmd: "rote tool ..."` but more efficient since it doesn't spawn a new process for each healthcheck.

### Example: Full-Stack Application

```yaml
Expand All @@ -102,36 +135,42 @@ tasks:
cwd: backend
ensure: bash -c '[ -f .env ] || cp env_template .env'

# Install dependencies:
# Install dependencies
frontend-install:
cwd: frontend
ensure: npm install

# Database
# Database with healthcheck - migrations wait until postgres is accepting connections
postgres:
run: docker run --rm -p 5432:5432 -e POSTGRES_PASSWORD=dev postgres
display: [stderr]
healthcheck:
tool: is-port-open 5432
interval: 0.5

# Run migrations after DB is ready
# Run migrations after DB is ready (healthcheck must pass first)
migrate:
ensure: run-migrations.sh
require: [postgres, install]
ensure: ./run-migrations.sh
require: [postgres]

# Backend server
# Backend server with healthcheck - frontend waits until API is responding
api:
cwd: backend
run: cargo run --bin api
require: [migrate, init-config]
healthcheck:
tool: http-get 8080
interval: 1

# Frontend dev server
# Frontend dev server - starts after API is healthy
web:
cwd: frontend
run: npm run http-server
require: [install]
run: npm run dev
require: [frontend-install, api]

# Development target
dev:
require: [api, web]
require: [web]
```

### Display Streams
Expand Down
16 changes: 16 additions & 0 deletions example.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -15,5 +15,21 @@ tasks:
autorestart: true
setup-task:
ensure: true
healthcheck-demo:
run: bash -c 'echo "Starting service..."; sleep 2; echo "Service ready"; while true; do sleep 1; done'
healthcheck:
cmd: "true"
interval: 1
healthcheck-tool-demo:
run: bash -c 'echo "Waiting..."; sleep 5; echo "Starting port listener..."; nc -l 12345; sleep 5; echo "Done"'
autorestart: true
healthcheck:
tool: is-port-open 12345
interval: 0.5
healthcheck-http-demo:
run: bash -c 'echo "Waiting for google.com to be reachable..."; sleep infinity'
healthcheck:
tool: http-get-ok https://www.google.com
interval: 1
ping-demo:
require: [google-ping, cloudflare-ping, short-lived, auto-restarting]
3 changes: 2 additions & 1 deletion rote/Cargo.toml
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
[package]
name = "rote-mux"
version = "0.1.4"
version = "0.1.5"
edition = "2024"
description = "A terminal multiplexer for monitoring and managing multiple processes"
license = "MIT"
Expand All @@ -26,3 +26,4 @@ serde = { version = "1.0.228", features = ["derive"] }
serde_yaml = "0.9.34"
shell-words = "1.1.1"
unicode-width = "0.1"
reqwest = { version = "0.12", default-features = false, features = ["rustls-tls"] }
Loading