Skip to content

Commit

Permalink
Merge pull request #234 from apigee-internal/b133195226
Browse files Browse the repository at this point in the history
Reload crashes EdgeMicro 2.5.35
  • Loading branch information
srinandan authored May 23, 2019
2 parents 8fdd05e + 56b7131 commit d096130
Show file tree
Hide file tree
Showing 4 changed files with 18 additions and 12 deletions.
24 changes: 14 additions & 10 deletions cli/lib/gateway.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,7 @@ const defaultPollInterval = 600;
const uuid = require('uuid/v1');
const debug = require('debug')('microgateway');
const jsdiff = require('diff');
const _ = require('lodash');

const Gateway = function() {};

Expand Down Expand Up @@ -326,19 +327,22 @@ function hasConfigChanged(oldConfig, newConfig) {
//do not compare uid
delete oldConfig['uid'];

var diff = jsdiff.diffWords(JSON.stringify(oldConfig), JSON.stringify(newConfig));
if (diff.length == 1) {

if (_.isEqual(oldConfig, newConfig)) {
debug("no changes detected");
return false;
} else {
diff.forEach(function(part) {
if (part.added)
debug("Added->" + part.value);
else if (part.removed)
debug("Removed->" + part.value);
else
debug("Unchanged->" + part.value);
});
if (debug.enabled) {
var diff = jsdiff.diffWords(JSON.stringify(oldConfig), JSON.stringify(newConfig));
diff.forEach(function(part) {
if (part.added)
debug("Added->" + part.value);
else if (part.removed)
debug("Removed->" + part.value);
else
debug("Unchanged->" + part.value);
});
}
return true;
}
}
Expand Down
2 changes: 2 additions & 0 deletions cli/lib/reload-cluster.js
Original file line number Diff line number Diff line change
Expand Up @@ -254,6 +254,8 @@ var ReloadCluster = (file, opt) => {
*/
self.reload = function (cb) {
if (!cluster.isMaster) return;
//clear the cache before terminating the process
cache.clear(function(){});
respawnerTimers.clear();

function allReady(cb) {
Expand Down
2 changes: 1 addition & 1 deletion npm-shrinkwrap.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
{
"name": "edgemicro",
"version": "2.5.35",
"version": "2.5.36",
"description": "Apigee Edge Microgateway",
"main": "index.js",
"license": "Apache-2.0",
Expand Down

0 comments on commit d096130

Please sign in to comment.