Minimal lightweight task orchestrator in Rust
https://github.com/PedramNavid/petit.git
A minimal, lightweight task orchestrator with cron-like scheduling, written in Rust.
I wanted something to orchestrate simple tasks on embedded hardware (Turing PI cluster with RK1 and Raspberry PIs). Low-memory and efficiency were important, but I also wanted something that was usable and friendly.
Importantly, I needed
No! I built this to see what it would take to build an orchestrator with Claude Code using Opus 4.5. It works for me but please do not use it for you.
api โ Enables HTTP REST API and related CLI flags (--no-api, --api-port, --api-host). Enabled by default.sqlite โ Enables SQLite storage backend and --db CLI flagtui โ Enables terminal UI dashboard (includes sqlite)# Default installation (includes API feature)
cargo install --path .
# With SQLite support
cargo install --path . --features sqlite
# With TUI support
cargo install --path . --features tui
# Minimal installation (no API, no SQLite)
cargo install --path . --no-default-features
There are example jobs in ./examples. You can use those or follow these instructions:
# jobs/hello.yaml
id: hello_world
name: Hello World Job
tasks:
- id: greet
type: command
command: echo
args: ["Hello, World from Petit!"]
pt run jobs/
pt trigger jobs/ hello_world
By default, this runs in-memory with no persistence!
pt trigger jobs/ hello_world --db petit.db
pt run <jobs-dir> # Run scheduler with jobs from directory
pt validate <jobs-dir> # Validate job configurations
pt list <jobs-dir> # List all jobs
pt trigger <jobs-dir> <job-id> # Trigger a job manually
run| Flag | Description |
|---|---|
-j, --max-jobs <N> | Maximum concurrent jobs (default: unlimited) |
-t, --max-tasks <N> | Maximum concurrent tasks per job (default: 4) |
--tick-interval <N> | Scheduler tick interval in seconds (default: 1) |
--db <PATH> | Path to SQLite database file (requires sqlite feature) |
--no-api | Disable HTTP API server (requires api feature, enabled by default) |
--api-port <PORT> | API server port (default: 8565, requires api feature) |
--api-host <HOST> | API server host (default: 127.0.0.1, requires api feature) |
--no-api, --api-port, --api-host) are only available when the api feature is enabled (which is the default). If you compile with --no-default-features, these flags will not be available and no API server will start.
Jobs are defined in YAML files:
id: data_pipeline
name: Data Pipeline
schedule: "0 0 2 * * *" # 2 AM daily (6-field cron: sec min hour day month weekday)
enabled: true
max_concurrency: 1
config:
batch_size: 1000
output_dir: /tmp/data
tasks:
- id: extract
type: command
command: python
args: ["scripts/extract.py"]
environment:
STAGE: extract
- id: transform
type: command
command: python
args: ["scripts/transform.py"]
depends_on: [extract]
condition: all_success
retry:
max_attempts: 3
delay_secs: 10
condition: always
- id: notify
type: command
command: echo
args: ["Pipeline done"]
depends_on: [transform]
condition: all_done # Runs regardless of upstream success/failure
| Condition | Description |
|---|---|
always | Run if dependencies completed (default) |
all_success | Run only if all upstream tasks succeeded |
on_failure | Run only if at least one upstream task failed |
all_done | Run after dependencies complete, regardless of status |
retry:
max_attempts: 3 # Number of retries (0 = no retries)
delay_secs: 5 # Fixed delay between attempts
condition: always # always | transient_only | never
id: downstream_job
name: Downstream Job
depends_on:
- job_id: upstream_job
condition: last_success # last_success | last_complete | within_window
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ CLI โ
โ run | validate | list | trigger โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ Scheduler โ
โ โข Cron scheduling โข Job dependencies โ
โ โข Pause/resume โข Concurrency control โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ DagExecutor โ
โ โข Topological ordering โข Parallel execution โ
โ โข Task conditions โข Context propagation โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโฌโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ TaskExecutor โ
โ โข Retry logic โข Timeout handling โ
โ โข CommandTask โข Custom Task trait โ
โโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโโ
โ
โโโโโโโโโโโโโโโโโผโโโโโโโโโโโโโโโโ
โผ โผ โผ
โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโ
โ Storage โ โ EventBus โ โ Context โ
โโโโโโโโโโโ โโโโโโโโโโโโ โโโโโโโโโโโโโ
# Run tests
cargo test
# Run tests with SQLite
cargo test --features sqlite
# Build release
cargo build --release
# Run with debug logging
RUST_LOG=debug cargo run -- run examples/jobs/
MIT