From aj-geddes-useful-ai-prompts-4
Implements graceful shutdown for SIGTERM signals, draining connections, completing in-flight requests, and cleaning resources. For containerized apps, server restarts, zero-downtime deployments.
npx claudepluginhub joshuarweaver/cascade-code-languages-misc-1 --plugin aj-geddes-useful-ai-prompts-4This skill uses the workspace's default tool permissions.
- [Overview](#overview)
Searches, retrieves, and installs Agent Skills from prompts.chat registry using MCP tools like search_skills and get_skill. Activates for finding skills, browsing catalogs, or extending Claude.
Searches prompts.chat for AI prompt templates by keyword or category, retrieves by ID with variable handling, and improves prompts via AI. Use for discovering or enhancing prompts.
Checks Next.js compilation errors using a running Turbopack dev server after code edits. Fixes actionable issues before reporting complete. Replaces `next build`.
Implement proper shutdown procedures to ensure all requests are completed, connections are closed, and resources are released before process termination.
Minimal working example:
import express from "express";
import http from "http";
class GracefulShutdownServer {
private app: express.Application;
private server: http.Server;
private isShuttingDown = false;
private activeConnections = new Set<any>();
private shutdownTimeout = 30000; // 30 seconds
constructor() {
this.app = express();
this.server = http.createServer(this.app);
this.setupMiddleware();
this.setupRoutes();
this.setupShutdownHandlers();
}
private setupMiddleware(): void {
// Track active connections
this.app.use((req, res, next) => {
if (this.isShuttingDown) {
res.set("Connection", "close");
return res.status(503).json({
error: "Server is shutting down",
// ... (see reference guides for full implementation)
Detailed implementations in the references/ directory:
| Guide | Contents |
|---|---|
| Express.js Graceful Shutdown | Express.js Graceful Shutdown |
| Kubernetes-Aware Shutdown | Kubernetes-Aware Shutdown |
| Worker Process Shutdown | Worker Process Shutdown |
| Database Connection Pool Shutdown | Database Connection Pool Shutdown |
| PM2 Graceful Shutdown | PM2 Graceful Shutdown |
| Python/Flask Graceful Shutdown | Python/Flask Graceful Shutdown |