Skip to content

Commit 0afd484

Browse files
committed
Fixed bug where if mongo was not there on start up, it would go into zombie mode. Now it just exits.
1 parent 811abc4 commit 0afd484

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

lib/mongoHandler.js

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -196,6 +196,7 @@ MongoStore.prototype.initialise = function(resourceConfig) {
196196
}).then(function(db) {
197197
self._db = db;
198198
//Set a keep alive timer.
199+
console.log('Successfully connected to mongo.');
199200
timers.setTimeout(self.keepAlive.bind(self), KEEP_ALIVE_TIMER_MS);
200201
self._db.on("timeout", function() {
201202
console.error("mongodb connection timeout.");
@@ -207,13 +208,16 @@ MongoStore.prototype.initialise = function(resourceConfig) {
207208
self.ready = false;
208209
self.initialise(resourceConfig);
209210
});
210-
}).catch(function(err) {
211-
console.error("mongodb connection failed:", err.message);
212211
}).then(function() {
213212
var resourceName = resourceConfig.resource;
214213
var collection = self._db.collection(resourceName);
215214
self._createIndexesForRelationships(collection, self.relationshipAttributeNames);
216215
self.ready = true;
216+
}).catch(function(err) {
217+
console.error("mongodb connection failed:", err.message);
218+
setTimeout(function () {
219+
process.kill(process.pid, 'SIGTERM');
220+
}, 5000);
217221
});
218222
};
219223

0 commit comments

Comments
 (0)