Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Zero Downtime reload config capability #55

Merged
merged 5 commits into from
Oct 24, 2016
Merged

Zero Downtime reload config capability #55

merged 5 commits into from
Oct 24, 2016

Conversation

vk4u
Copy link
Collaborator

@vk4u vk4u commented Oct 6, 2016

  1. Introducing ability to reload microgateway for new config without dropping messages.
  2. Reloading is done using IPC through sockets.
  3. After this change, microgateway will always be starting in cluster mode.
  4. Owing to this there are 3 new commands added. Status, Reload, Stop.

…dropping messages.

2. Reloading is done using IPC through sockets.
3. After this change, microgateway will always be starting in cluster mode.
4. Owing to this there are 3 new commands added. Status, Reload, Stop.
.option('-e, --env <env>', 'the environment')
.option('-k, --key <key>', 'key for authenticating with Edge')
.option('-s, --secret <secret>', 'secret for authenticating with Edge')
.description('reoad the edgemicro cluster by pulling new configuration')
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

reoad typo.

@mdobson
Copy link
Contributor

mdobson commented Oct 11, 2016

Aside from the typo this looks ok to me. 👍

Copy link
Contributor

@f1erro f1erro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Great additions, just a few comments. Nice!

}
}
});
run.start(options);
Copy link
Contributor

@f1erro f1erro Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Are we removing the callback because the success/error messages are logged in the start-agent?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yes. That is true. Moreover, the callback isn't available anymore. Because the we are passing the start file to cluster.setupMaster now.

opt.args = [JSON.stringify(args)];
opt.timeout = 10;

var cluster = reloadCluster(path.join(__dirname, 'start-agent.js'), opt);
Copy link
Contributor

@f1erro f1erro Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think this should be declared above line 66 so that the cluster reference is obvious. Also, please rename cluster to something else (perhaps mgCluster) so that it is not confused with the Node cluster module. When I see a variable named cluster in Node I think var cluster = require('cluster');

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sure. Made the changes.

edgeconfig.save(config, cache);
}

gateway(config);
Copy link
Contributor

@f1erro f1erro Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I believe this does nothing, please delete line 59

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Interesting. Ill remove it. But just curious to know what it was doing earlier ?

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

great question, no idea, it's been there since this odd commit
d065991

for (var i = 0; i < numWorkers; i++) {
cluster.fork();
}
gateway(config);
Copy link
Contributor

@f1erro f1erro Oct 11, 2016

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

same as above, please remove line 136 (even though it was already present, may as well take the chance to clean it up)

Vinoth Kumar Pethaiyan added 2 commits October 12, 2016 17:10
Copy link
Contributor

@f1erro f1erro left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

looks good

@@ -107,6 +106,40 @@ Gateway.prototype.start = (options) => {
process.exit(0);
});

var pollInterval = config.edgemicro.config_change_poll_interval ? config.edgemicro.config_change_poll_interval : defaultPollInterval;
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

var pollInterval = config.edgemicro.config_change_poll_interval || defaultPollInterval

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

function hasConfigChanged(oldConfig, newConfig) {
// This may not be the best way to do the check. But it works for now.
if (JSON.stringify(oldConfig) == JSON.stringify(newConfig)) {
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

return JSON.stringify(oldConfig) != JSON.stringify(newConfig)

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Done.

@mdobson mdobson merged commit 2891d93 into master Oct 24, 2016
@mdobson mdobson deleted the reload_config_v2 branch February 17, 2017 02:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants