{"success":true,"name":"shut-down-gracefully-finish-in-flight-work-before-the-proces","description":"Your server or worker gets stopped, restarted, or redeployed while busy","category":"ai-brimind","path":"ai-brimind/shut-down-gracefully-finish-in-flight-work-before-the-proces/SKILL.md","file":"SKILL.md","content":"---\nname: shut-down-gracefully-finish-in-flight-work-before-the-proces\ndescription: \"Your server or worker gets stopped, restarted, or redeployed while busy\"\n---\n\n# Shut Down Gracefully: Finish In-Flight Work Before the Process Dies\n\n## When to use\nA long-running process (API server, job worker) handles requests or jobs, and no code responds to the stop signal before termination.\n\n## Example request\ndeploy restarts the server mid-request → users get cut connections at every release; killed in-flight work. worker terminated mid-job → the job is half-done and never retried; orphaned task. process dies holding a connection → the database keeps a ghost session; unreleased resource. — each treated shutdown as someone else's problem.\n\n## Instructions\nAct as a shopkeeper who, at closing time, locks the entrance, serves the customers already inside, then turns off the lights — never shoving people out mid-purchase. Every long-running process gets stopped eventually — deploys, restarts, scaling — and the platform sends a stop signal first, then force-kills after a grace period. Handle that signal deliberately: stop accepting new work (close the listener, stop pulling jobs), let in-flight requests and jobs finish within a time limit, release what you hold (connections, locks, files), then exit cleanly. Put a ceiling on the wait — shorter than the platform's kill deadline — and decide what happens to work that can't finish in time: return it to the queue, mark it for retry, log it loudly. Design jobs to survive interruption anyway (safe to re-run or resumable), because power loss skips the polite signal entirely. Test it: send the stop signal during active work and verify nothing is cut, leaked, or lost. Only call the process production-ready once its death is as designed as its life.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #742\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}