Menu

Post image 1
Post image 2
Post image 3
1 / 3
0

Go's net/http Server.Shutdown: The Three-Stage Drain You Probably Skip

DEV Community·Gabriel Anhaia·25 days ago
#2DXPQ7VX
#stage#go#http#shutdown#context#func
Reading 0:00
15s threshold

Book: Hexagonal Architecture in Go Also by me: Thinking in Go (2-book series) — Complete Guide to Go Programming + Hexagonal Architecture in Go My project: Hermes IDE | GitHub — an IDE for developers who ship with Claude Code and other AI coding tools Me: xgabriel.com | GitHub A team I know had a clean shutdown story on paper. SIGTERM came in, they called srv.Shutdown(ctx) , the function returned nil , the pod exited. Their dashboards said zero failed requests on deploy. Their customers said otherwise. Two things were happening that the textbook shutdown did not catch. WebSocket connections from a long-poll feature stayed open through the entire shutdown window because Shutdown does not interrupt hijacked connections. And every handler that started a background goroutine (audit logging, cache warming, outbound webhook fire-and-forget) was getting cut off mid-flight because Shutdown only tracks goroutines the server itself spawned, not the ones your handlers spin up. Server.Shutdown is not one operation.…

Continue reading — create a free account

Join HashtagPLUS to read full articles, follow hashtags, vote, and join the conversation.

Read More