v2.2.0: Lifecycle hooks for stop and exit, scoped daemon startup
Pitchfork v2.2.0 adds two new lifecycle hooks (on_stop and on_exit) for running cleanup or notification commands when daemons terminate, and introduces --local / --global flags on pitchfork start so you can selectively start only project-level or system-level daemons.
Highlights
on_stopandon_exithooks: Run custom commands when a daemon is explicitly stopped by pitchfork or when it terminates for any reason (stop, crash, or clean exit). NewPITCHFORK_EXIT_REASONenvironment variable lets hooks distinguish the cause.- Scoped
startflags:pitchfork start --localstarts only daemons from your project'spitchfork.toml, while--globaltargets only daemons from~/.config/pitchfork/config.tomland/etc/pitchfork/config.toml. The existing--allflag now explicitly means "both local and global."
Added
-
on_stopandon_exitlifecycle hooks -- Two new hook types let you react to daemon termination.on_stopfires when a daemon is explicitly stopped by pitchfork (viapitchfork stop,auto = ["stop"]directory exit, or supervisor shutdown).on_exitfires on any termination -- intentional stop, clean exit, or crash. For daemons with retries,on_exitfires only after all retries are exhausted. Both hooks receivePITCHFORK_EXIT_CODEandPITCHFORK_EXIT_REASONenvironment variables. Hook tasks are now tracked during supervisor shutdown so they complete reliably instead of being silently dropped. (#291) - @gaojunran[daemons.infra] run = "docker compose up" [daemons.infra.hooks] on_stop = "./scripts/notify-stopped.sh" on_exit = "docker compose down --volumes"
The
PITCHFORK_EXIT_REASONvariable is set to"stop","exit", or"fail"depending on why the daemon terminated. Also available viapitchfork config add --on-stopand--on-exit. -
pitchfork start --localandpitchfork start --global-- New-l/--localand-g/--globalflags allow starting only project-level or only global daemons, respectively. Previously--allwas the only batch option and it started everything. The--allflag continues to work and now explicitly means "both local and global." (#282) - @gaojunranpitchfork start -l # Start all daemons from local pitchfork.toml pitchfork start -g # Start all daemons from global config pitchfork start -a # Start all daemons (both local and global)
Full Changelog: v2.1.0...v2.2.0