mirror of
https://github.com/lukaszraczylo/graphql-monitoring-proxy.git
synced 2026-10-20 06:28:13 +00:00
fix(server): gracefully shut down HTTP proxy to drain in-flight requests
On signal, main waited on wg for StartHTTPProxy's server.Listen, which never returns because nothing called server.Shutdown(); it timed out after 10s and process-exited, abruptly killing in-flight GraphQL requests. Expose the proxy Fiber app and register an http-proxy Shutdown component so server.Listen returns after Shutdown, letting connections drain. Guard the shared app handle with a mutex (written by the StartHTTPProxy goroutine, read by the shutdown component). Verified with build, vet, full test and full race suite.
This commit is contained in:
@@ -612,6 +612,10 @@ func main() {
|
||||
return nil
|
||||
})
|
||||
|
||||
// Register HTTP proxy so in-flight requests drain gracefully on shutdown
|
||||
// instead of being cut off when the process exits.
|
||||
shutdownManager.RegisterComponent("http-proxy", shutdownHTTPProxy)
|
||||
|
||||
// Cache shutdown is handled internally by the cache implementation
|
||||
|
||||
// Start monitoring server
|
||||
|
||||
Reference in New Issue
Block a user