The actual HTTP server instance can be killed with server.close(callback)
, but I'm not sure what will happen with any pending WebSocket operations (mutations or queries being run through WebSockets). Since http.Server doesn't really know anything about the WebSocket operations, it probably ignores them. How to properly make sure that when SIGTERM is received, the server stops accepting new requests/webSocket connections, finishes the pending ones and then closes?
Couldn't really find anything about this with Google.
Assuming based on the year this question was asked that you are asking about ApolloServer v2. Apollo Server instance does provide
stop
function which as per documentation waits for all the background tasks running. So it will wait for existing queries to complete before terminating the server. The method is available for v3 as well.