Notification on Mimosa server reload?

17 views
Skip to first unread message

Ken Carpenter

unread,
Jun 19, 2014, 1:34:52 PM6/19/14
to mimo...@googlegroups.com
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

David Bashford

unread,
Jun 20, 2014, 4:31:40 PM6/20/14
to mimo...@googlegroups.com

Well, here's how server-reload restarts your server...
  mimosaServer.startServer localConfig, options, ->
    logger.debug "Calling refresh live reload"
    __refreshLiveReload options


Couldn't you just keep track of whether or not the server has been started and when startServer is called, if it had been started before, clean up mongo?  Probably just 3ish lines of code on top of the code you'd have to write either way to clean things up.  Set a flag, check a flag and call a function.

k...@oboe.io

unread,
Jun 23, 2014, 12:42:41 PM6/23/14
to mimo...@googlegroups.com
Sure, I *could* do that, but that would only help me. Just wanted to see if there was something I missed that might help here. :-)

I'll just do that for now and look at maybe integrating it into Mimosa later.

Thanks.

David Bashford

unread,
Jun 23, 2014, 2:15:41 PM6/23/14
to mimo...@googlegroups.com
I think it may be pretty easy to call a function if the function exists.  Let me take a peek.



--
You received this message because you are subscribed to the Google Groups "mimosajs" group.
To unsubscribe from this group and stop receiving emails from it, send an email to mimosajs+u...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

David Bashford

unread,
Jun 23, 2014, 3:27:40 PM6/23/14
to mimo...@googlegroups.com
Give it a looksee.  Let me know if it works for you.

Ken Carpenter

unread,
Jun 24, 2014, 1:29:47 PM6/24/14
to mimo...@googlegroups.com
Cool, thanks!  I'll give it a try tonight.

Would preServerRestart maybe be a better name than preMimosaRestart, since you are restarting the server, not Mimosa (also more consistent with serverStart name)?




You received this message because you are subscribed to a topic in the Google Groups "mimosajs" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/mimosajs/x9R0bdlLM8Q/unsubscribe.
To unsubscribe from this group and all its topics, send an email to mimosajs+u...@googlegroups.com.

k...@oboe.io

unread,
Jun 24, 2014, 2:06:26 PM6/24/14
to mimo...@googlegroups.com, k...@oboe.io
On Tuesday, June 24, 2014 10:29:47 AM UTC-7, Ken Carpenter wrote:
> Cool, thanks!  I'll give it a try tonight.
>
>
> Would preServerRestart maybe be a better name than preMimosaRestart, since you are restarting the server, not Mimosa (also more consistent with serverStart name)?

Ooops...it's startServer, not serverStart. Maybe preRestartServer?
Reply all
Reply to author
Forward
0 new messages