If I receive a SIGINT/SIGTERM (e.g. ctrl+c) then I must gracefully stop my app and close all connections to the mongodb server.
Most documentation/tutorials state that to stop a connection (or
pool of connections), I must use mongoose.disconnect()
- which calls .close()
on connections in the pool.
However all those docs also say this should be done after all pending writes are completed.
How can I know this when I receive a signal event (e.g. SIGINT, SIGTERM, etc.)? Does mongoose have graceful shutdown functionality, or will I lose data when I call disconnect()
?
(I'm using the latest bits.)