How do I do cleanup on workers when gracefully restarting?
thelinuxlich opened this issue · comments
What event should I be listening to? Also, does cluster-service spawns new workers before the timeout to kill old workers, so old workers won't receive new requests while doing cleanup?
By default cservice assumes no cleanup is required, and socket management is handled automatically (bind is closed and pre-existing connections are given time to finish). However some apps require manual cleanup, and can leverage Async support: https://github.com/godaddy/node-cluster-service#async-support
Registering onWorkerStop
callback means you'll be responsible for exiting the process after everything you cleanup is complete. Ideally the process will exit automatically once there are no open handles, but as apps get bigger it's more likely you forgot to close a handle, and should just process.exit()
once cleanup is done to be safe, to avoid timeouts.
Closing this issue unless you still had questions.