LearnBoost / cluster

Node.JS multi-core server manager with plugins support.

Home Page:http://learnboost.github.com/cluster

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Reload plugin preventing cli plugin exit

jimisaacs opened this issue · comments

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.

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?

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

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.

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