LearnBoost / cluster

Node.JS multi-core server manager with plugins support.
http://learnboost.github.com/cluster
MIT License
2.29k stars 159 forks source link

Reload plugin preventing cli plugin exit #155

Open jimisaacs opened 13 years ago

jimisaacs commented 13 years ago

I'm not sure what is exactly going on here since I just started testing with the provided cluster examples. Basically when I add the reload plugin to the cli test, then try to use it as described, it behaves differently than without the reload plugin.

It looks like the reload plugin is somehow preventing the cli plugin from properly exiting the process on say simple: node cli.js -h

It shows the help, no errors, simply doesn't exit as it does without using the reload plugin.

jimisaacs commented 13 years ago

I assume fs.watchFile is in use in the reload plugin, and I remember finding out that this keeps the process open the same as opening a socket.

Maybe this is what is happening here?

tj commented 13 years ago

could be, probably not a bad idea to duplicate some of the tests with varied configurations

jimisaacs commented 13 years ago

Ok, so I had a look at the reload plugin and yes, watchFile is in use, so I wondered if it had anything to do with the order plugins are enabled, so switched them around. This isn't the case, because the plugin looks to be invoked immediately with the Master.prototype.use method.

Do you think there a need for a set of deferred plugins? Where these plugins wouldn't be invoked until the cluster actually starts, or some state is entered. This way, if the reload plugin and the cli plugin are both used, the reload plugin will not be invoked at all if we simply want to run a cli option.

There's probably more use cases for this I can't think of right now, but just a thought. I guess this sounds like a plugin api allowing for priority. Might be able to achieve something else just with events and listeners, eg. the plugin is invoked, but the main body of the plugin is simply added as listener for an event emitted by the master.

jimisaacs commented 13 years ago

I have horrible habit of doing that... (hitting Comment & Close)