This folder contains runnable examples demonstrating various features of the lifecycle library.
These examples demonstrate the core "Death Management" features (v1.0-v1.4). Ideal for CLIs, Scripts, and simple Tools.
- basic: The "Hello World" of
lifecycle. ShowsRun,Go, andJob. - context: Manual setup via
lifecycle.Context()for gradual migration. - hooks: How to register and execute synchronous/asynchronous cleanup hooks.
- interactive_dx: Safe reading from Stdin (Windows
CONIN$support) that respects context cancellation.
These examples demonstrate "Life Management" capabilities (v1.5+). Ideal for Services, Daemons, and Agents.
- suspend: The full Control Plane experience. Shows Supervisors, Suspend/Resume events, and Durable Execution.
- supervisor: Managing a tree of child processes/workers with restart policies.
- repl: Building an interactive REPL that handles signals and custom commands.
Specific solutions to common problems.
- zombie: Demonstrating Process Hygiene (Job Objects / PDeathSig) to ensure child processes die with the parent.
- reliability: Using
lifecycle.Dofor safe execution. - observability: Visualizing the system state with Mermaid.