/** * Test fixture: a hook that traps SIGTERM and keeps going. * * SIGTERM is a request. This is the case that makes the grace period load * bearing: without the SIGKILL that follows it, a hook can decline to die and * the boundary buys nothing over the promise race it replaced. */ import { writeFileSync } from 'node:fs'; import { defineHook } from '@celilo/capabilities'; export default defineHook({ hook: 'container_created', requires: [], handler: async (ctx) => { process.on('SIGTERM', () => ctx.logger.info('declining to die')); ctx.logger.info('sigterm-ignoring hook starting'); await new Promise((r) => setTimeout(r, Number(ctx.config.sleep_ms ?? 20_000))); writeFileSync(String(ctx.config.marker_path), 'survived SIGTERM\n'); }, });