Moved ping to its own controller

re: #6281
v1.18.x
Julian Lam 7 years ago
parent f7aa32cd05
commit a4939d78fe

@ -0,0 +1,11 @@
{
"url": "http://127.0.0.1:4567",
"secret": "catsRkool",
"database": "redis",
"port": 4567,
"redis": {
"host": "127.0.0.1",
"port": "6379",
"database": "0"
}
}

@ -11,6 +11,7 @@ var helpers = require('./helpers');
var Controllers = module.exports;
Controllers.ping = require('./ping');
Controllers.home = require('./home');
Controllers.topics = require('./topics');
Controllers.posts = require('./posts');

@ -0,0 +1,15 @@
'use strict';
var async = require('async');
var db = require('../database');
module.exports.ping = function (req, res, next) {
async.waterfall([
function (next) {
db.getObject('config', next);
},
function () {
res.status(200).send(req.path === '/sping' ? 'healthy' : '200');
},
], next);
};

@ -116,6 +116,7 @@ function initializeNodeBB(callback) {
function setupExpressApp(app, callback) {
var middleware = require('./middleware');
var pingController = require('./controllers/ping');
var relativePath = nconf.get('relative_path');
var viewsDir = nconf.get('views_dir');
@ -147,8 +148,8 @@ function setupExpressApp(app, callback) {
app.use(compression());
app.get(relativePath + '/ping', ping);
app.get(relativePath + '/sping', ping);
app.get(relativePath + '/ping', pingController.ping);
app.get(relativePath + '/sping', pingController.ping);
setupFavicon(app);
@ -179,17 +180,6 @@ function setupExpressApp(app, callback) {
setupAutoLocale(app, callback);
}
function ping(req, res, next) {
async.waterfall([
function (next) {
db.getObject('config', next);
},
function () {
res.status(200).send(req.path === '/sping' ? 'healthy' : '200');
},
], next);
}
function setupFavicon(app) {
var faviconPath = meta.config['brand:favicon'] || 'favicon.ico';
faviconPath = path.join(nconf.get('base_dir'), 'public', faviconPath.replace(/assets\/uploads/, 'uploads'));

Loading…
Cancel
Save