Skip to content

v0.42.0 — lifecycle hooks & graceful shutdown

Choose a tag to compare

@tshafer tshafer released this 11 Jul 06:47
· 116 commits to main since this release

Application lifecycle hooks, inspired by Fastify's hooks — scoped to the parts Keel doesn't already cover (request-lifecycle hooks are middleware).

  • onReady(hook) runs once the app has booted (or immediately if already booted).
  • onShutdown(hook) + terminate() — graceful shutdown: run cleanup newest-first (LIFO) to close DB/Redis connections and flush queues on SIGTERM. terminate() is idempotent, and a throwing hook can't strand the others (first error re-thrown after all run).
  • Router.onRoute(hook) observes route registration — fired live and replayed for existing routes.

Available as Application methods and global helpers. 268 tests; type-checked doc examples. See docs/hooks.md.