worker.disconnect()
The cluster method that tells a worker to stop accepting new connections, finish its current ones and then exit.
In more detail
worker.kill() instead ends the process at once with a signal. The worker emits disconnect when its IPC channel closes and exit when the process ends.
Related terms
- worker process — One of the processes forked by a cluster's primary to handle requests, each with its own memory and event loop.
- connection draining — Stopping new traffic to a backend while letting its existing connections finish, before removing or restarting it.
Taught in
- Cluster Architecture: node:cluster & Zero-Downtime — Node.js Internals & Backend Services