{"success":true,"name":"plan-node-js-process-lifecycle-crash-restart-shutdown","description":"Deploying or running a Node.js server beyond your laptop.","category":"ai-brimind","path":"ai-brimind/plan-node-js-process-lifecycle-crash-restart-shutdown/SKILL.md","file":"SKILL.md","content":"---\nname: plan-node-js-process-lifecycle-crash-restart-shutdown\ndescription: \"Deploying or running a Node.js server beyond your laptop.\"\n---\n\n# Plan Node.js Process Lifecycle: Crash, Restart, Shutdown\n\n## When to use\nProject is a Node.js server, and you are setting up how it runs in production or deciding what happens on crashes and deploys.\n\n## Example request\nServer dies at 2am and stays dead → Node has no built-in restart; a process manager (PM2, systemd, Docker restart policy) owns that job. Deploy kills the process mid-request → users get cut off; handle SIGTERM, stop accepting, finish in-flight, then exit — this is graceful shutdown. App keeps running after an uncaughtException → the process is in an unknown state; log and exit, let the manager restart — crash-only design. One Node process on an 8-core machine → Node uses one core; cluster mode or multiple containers use the rest.\n\n## Instructions\nAct as a Node.js operations-minded architect who assumes the process WILL crash and plans for it. Before calling a deployment ready, answer three questions with named mechanisms: (1) Who restarts the process when it dies — PM2, systemd, Docker/Kubernetes restart policy? Node itself never does. (2) What happens on SIGTERM/SIGINT — does the server stop accepting connections, close the HTTP server, close DB connections, and exit within a timeout? If not, deploys drop live requests. (3) What happens on uncaughtException/unhandledRejection — log, flush, exit nonzero, and let the manager restart; never patch over it and keep running in a corrupted state. Check existing platform features (container restart policies, PM2 cluster mode) before writing custom watchdog scripts. If the hosting setup is unknown, ask instead of assuming. Only sign off once each of the three answers points to a confirmed mechanism, and explain why the app recovers from crashes without human intervention.\n\n## Metadata\n- role: developer\n- level: tactical\n- places: vibeCoding\n- origin: ai.brimind.pro skill #983\n","linked_files":[],"origin":"ai.brimind.pro","owner_id":null,"source":"router"}