Skip to content

Commit 6b04abf

Browse files
author
Danny Diekroeger
committed
only close db connection if there is a connection. only connect to db if it is needed
1 parent 9c7fea7 commit 6b04abf

File tree

2 files changed

+5
-5
lines changed

2 files changed

+5
-5
lines changed

app/admin.js

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -424,7 +424,9 @@ const run = co(function *(testArgs) {
424424
yield handleRecoveryInfo(args);
425425
}
426426

427-
db.connection.close();
427+
if (db && db.connection) {
428+
db.connection.close();
429+
}
428430
});
429431

430432
// For admin script and unit testing of functions

bin/admin.js

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -4,10 +4,8 @@ const Promise = require('bluebird');
44
const admin = require('../app/admin');
55

66
Promise.try(admin.run).catch(function(e) {
7-
console.log('Error connecting to database, proceeding offline...');
8-
try {
7+
console.log(e.message);
8+
if (admin.db && admin.db.connection) {
99
admin.db.connection.close();
10-
} catch(e) {
11-
1210
}
1311
});

0 commit comments

Comments
 (0)