I noticed something unexpected today while working with server reload and mongodb.
When I pressed Ctrl-C to kill my Node server, I noticed that about a hundred mongod messages indicating "end connection", all with different port numbers.
I am using the newer MongoClient.connect() method of connecting which creates a connection pool, so at first I thought maybe it was just aggressive on the pool size.
Upon further investigation I discovered that it is related to Mimosa server reload.
My MongoClient.connect() call is called in the startServer() method, and that gets called every time Mimosa reloads the server.
Every time I save a file, I get another connection pool of 6 connections to Mongo and the other connections are essentially unusable, but still hang around until I hit Ctrl-C.
This is not a huge deal, since this occurs during development only, but it would be nice to close those old connections if possible.
Is there currently any way to get a notification when the server is about to be restarted so that we can disconnect from Mongo cleanly?
Thanks,
Ken