🤖 task-supervisor
task-supervisor helps you keep Tokio tasks alive.
It watches each task, restarts it if it crashes or stops responding, and lets you add, restart, or kill tasks at runtime.
Install
Quick example
use async_trait;
use ;
;
async
What you get
- Automatic restarts – tasks are relaunched after a crash or hang (exponential back-off).
- Dynamic control – add, restart, kill, or query tasks through a
SupervisorHandle. - Configurable – tune health-check interval, restart limits, back-off delay, and shutdown policy.
API overview
| TaskHandle method | Purpose |
|---|---|
add_task(name, task) |
Start a new task while running |
restart(name) |
Force a restart |
kill_task(name) |
Stop a task permanently |
get_task_status(name).await |
Return TaskStatus (Healthy, Failed, Completed, Dead, …) |
get_all_task_statuses().await |
Map of all task states |
shutdown() |
Stop every task and exit |
Full documentation lives on docs.rs.