79797681

Date: 2025-10-23 10:43:46
Score: 1
Natty:
Report link

There are lots of posts already about how to gracefully shutdown Node http servers:

Graceful shutdown of a node.JS HTTP server

Nodejs/express, shutdown gracefully

How do I shut down my Express server gracefully when its process is killed?

Quitting node.js gracefully

To also gracefully shutdown all open websocket connections, just add this to your shutdown handler:

for (const client of wss.clients) {
    client.close(1001, 'Server shutdown');
}
wss.close();
Reasons:
  • Blacklisted phrase (1): How do I
  • Probably link only (1):
  • Low length (0.5):
  • Has code block (-0.5):
  • High reputation (-1):
Posted by: Sámal Rasmussen