mirror of
https://github.com/NodeBB/NodeBB.git
synced 2025-10-29 18:16:17 +01:00
fix: db info page
if there is no connection to db, connect first
This commit is contained in:
@@ -450,19 +450,26 @@ postgresModule.checkCompatibilityVersion = function (version, callback) {
|
||||
};
|
||||
|
||||
postgresModule.info = function (db, callback) {
|
||||
if (!db) {
|
||||
return callback();
|
||||
}
|
||||
async.waterfall([
|
||||
function (next) {
|
||||
if (db) {
|
||||
setImmediate(next, null, db);
|
||||
} else {
|
||||
postgresModule.connect(nconf.get('postgres'), next);
|
||||
}
|
||||
},
|
||||
function (db, next) {
|
||||
postgresModule.pool = postgresModule.pool || db;
|
||||
|
||||
db.query(`
|
||||
SELECT true "postgres",
|
||||
current_setting('server_version') "version",
|
||||
EXTRACT(EPOCH FROM NOW() - pg_postmaster_start_time()) * 1000 "uptime"`, function (err, res) {
|
||||
if (err) {
|
||||
return callback(err);
|
||||
}
|
||||
callback(null, res.rows[0]);
|
||||
});
|
||||
db.query(`
|
||||
SELECT true "postgres",
|
||||
current_setting('server_version') "version",
|
||||
EXTRACT(EPOCH FROM NOW() - pg_postmaster_start_time()) * 1000 "uptime"`, next);
|
||||
},
|
||||
function (res, next) {
|
||||
next(null, res.rows[0]);
|
||||
},
|
||||
], callback);
|
||||
};
|
||||
|
||||
postgresModule.close = function (callback) {
|
||||
|
||||
Reference in New Issue
Block a user