{"id":26078119,"url":"https://github.com/akhercha/task-supervisor","last_synced_at":"2026-06-20T21:31:26.582Z","repository":{"id":281414195,"uuid":"944887432","full_name":"akhercha/task-supervisor","owner":"akhercha","description":"Smol Supervisor for long-lived tokio tasks","archived":false,"fork":false,"pushed_at":"2026-02-20T10:12:06.000Z","size":72,"stargazers_count":43,"open_issues_count":0,"forks_count":4,"subscribers_count":1,"default_branch":"main","last_synced_at":"2026-02-20T13:45:36.181Z","etag":null,"topics":["async","rust","tasks","tokio"],"latest_commit_sha":null,"homepage":"https://crates.io/crates/task-supervisor","language":"Rust","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/akhercha.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null,"zenodo":null,"notice":null,"maintainers":null,"copyright":null,"agents":null,"dco":null,"cla":null}},"created_at":"2025-03-08T06:53:07.000Z","updated_at":"2026-02-20T10:11:39.000Z","dependencies_parsed_at":"2025-03-08T23:24:24.679Z","dependency_job_id":"a40c1203-194d-4995-b532-603053825b9e","html_url":"https://github.com/akhercha/task-supervisor","commit_stats":null,"previous_names":["akhercha/task-supervisor"],"tags_count":15,"template":false,"template_full_name":null,"purl":"pkg:github/akhercha/task-supervisor","repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhercha%2Ftask-supervisor","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhercha%2Ftask-supervisor/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhercha%2Ftask-supervisor/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhercha%2Ftask-supervisor/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/akhercha","download_url":"https://codeload.github.com/akhercha/task-supervisor/tar.gz/refs/heads/main","sbom_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/akhercha%2Ftask-supervisor/sbom","scorecard":null,"host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":286080680,"owners_count":34586666,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2026-05-26T15:22:16.424Z","status":"online","status_checked_at":"2026-06-20T02:00:06.407Z","response_time":98,"last_error":null,"robots_txt_status":"success","robots_txt_updated_at":"2025-07-24T06:49:26.215Z","robots_txt_url":"https://github.com/robots.txt","online":true,"can_crawl_api":true,"host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["async","rust","tasks","tokio"],"created_at":"2025-03-09T03:49:48.920Z","updated_at":"2026-06-20T21:31:26.577Z","avatar_url":"https://github.com/akhercha.png","language":"Rust","funding_links":[],"categories":[],"sub_categories":[],"readme":"# task-supervisor\n\n[![Crates.io](https://img.shields.io/crates/v/supervisor.svg)](https://crates.io/crates/task-supervisor)\n[![Docs.rs](https://docs.rs/supervisor/badge.svg)](https://docs.rs/task-supervisor)\n\n`task-supervisor` helps you keep Tokio tasks alive.\nIt watches each task, restarts it if it crashes or stops responding, and lets you add, restart, or kill tasks at runtime.\n\n## Install\n\n```bash\ncargo add task-supervisor\n```\n\n## Features\n\n| Feature   | Effect                                       |\n| --------- | -------------------------------------------- |\n| `anyhow`  | Uses `anyhow::Error` as the task error type. |\n| `tracing` | Logs supervisor activity via `tracing`.      |\n\n## Quick example\n\n```rust\nuse task_supervisor::{SupervisorBuilder, SupervisedTask, TaskResult};\n\n#[derive(Clone)]\nstruct Printer;\n\nimpl SupervisedTask for Printer {\n        async fn run(\u0026mut self) -\u003e TaskResult {\n        println!(\"hello\");\n        Ok(())\n    }\n}\n\n#[tokio::main]\nasync fn main() {\n    let supervisor = SupervisorBuilder::default()\n        .with_task(\"printer\", Printer)\n        .build()\n        .run();\n\n    supervisor.wait().await.unwrap();   // wait until every task finishes or is killed\n}\n```\n\n## What you get\n\n* **Automatic restarts** – failed tasks are relaunched with exponential back-off.\n* **Dynamic control** – add, restart, kill, or query tasks at runtime through a `SupervisorHandle`.\n* **Configurable** – health-check interval, restart limits, back-off, dead-task threshold.\n\n## Usage\n\nBuild a supervisor with `SupervisorBuilder`, call `.build()` to get a `Supervisor`, then `.run()` to start it. This returns a `SupervisorHandle` you use to control things at runtime:\n\n| Method                          | Description                      |\n| ------------------------------- | -------------------------------- |\n| `wait().await`                  | Block until the supervisor exits |\n| `add_task(name, task)`          | Register and start a new task    |\n| `restart(name)`                 | Force-restart a task             |\n| `kill_task(name)`               | Stop a task permanently          |\n| `get_task_status(name).await`   | Get a task's `TaskStatus`        |\n| `get_all_task_statuses().await` | Get every task's status          |\n| `shutdown()`                    | Stop all tasks and exit          |\n\nThe handle auto-shuts down the supervisor when all clones are dropped.\n\n## Clone and restart behaviour\n\nEvery task must implement `Clone`. The supervisor stores the **original** instance and clones it each time the task is started or restarted. Mutations made through `\u0026mut self` in `run()` only affect the running clone and are lost on restart.\n\nTo share state across restarts, wrap it in an `Arc` (e.g. `Arc\u003cAtomicUsize\u003e`). Plain owned fields will always start from their original value. See the [`SupervisedTask`](https://docs.rs/task-supervisor/latest/task_supervisor/trait.SupervisedTask.html) docs for a full example.\n\n## License\n\n[MIT](./LICENSE)\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakhercha%2Ftask-supervisor","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fakhercha%2Ftask-supervisor","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fakhercha%2Ftask-supervisor/lists"}