You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
This repository has been archived by the owner on Apr 14, 2023. It is now read-only.
It's not clear how to make the WebSocket server stop accepting new connections, finish all pending operations and close the sockets, when SIGTERM is received. Has anyone dealt with this?
The text was updated successfully, but these errors were encountered:
Looks like the server does have a close() method that closes the WebSocket server. That definitely makes it stop accepting new connections.
But, looking at the ws code, it terminates all clients, which I'm pretty sure means it closes them immediately instead of waiting for pending operations to finish.
So instead of calling close() right away, you'd probably need to manually handle HTTP upgrade requests yourself so that you can stop passing them to the WebSocket server after you've received SIGTERM. For some examples on how to handle the upgrades manually, see apollographql/apollo-server#2314 (comment) and my gist linked earlier in that comment thread.
As far as waiting for pending operations to finish, I'm not 100% sure. You might need to put some middleware between each socket and subscriptions-transport-ws to stop accepting new subscription requests after SIGTERM is received.
That said, it does seem like this library would be the best place to perform a managed shutdown, if an API for it could be added.
It's not clear how to make the WebSocket server stop accepting new connections, finish all pending operations and close the sockets, when SIGTERM is received. Has anyone dealt with this?
The text was updated successfully, but these errors were encountered: