Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Following now show in /info command * Configuration * Current Masters / Slaves * Total commands, ReadOnly/Mutating, * Number of times redis server went up/down * Number of errors from server
- Loading branch information
Showing
5 changed files
with
50 additions
and
33 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,39 +1,41 @@ | ||
var express = require('express'); | ||
var stats = require('./stats'); | ||
var app = express(); | ||
module.exports = function(config){ | ||
var express = require('express'); | ||
var stats = require('./stats'); | ||
var app = express(); | ||
|
||
app.use(express.bodyParser()); | ||
app.use(express.methodOverride()); | ||
app.use(app.router); | ||
app.use(express.bodyParser()); | ||
app.use(express.methodOverride()); | ||
app.use(app.router); | ||
|
||
app.use(express.bodyParser()); | ||
app.use(express.methodOverride()); | ||
app.use(app.router); | ||
app.use(logErrors); | ||
app.use(clientErrorHandler); | ||
app.use(errorHandler); | ||
app.use(express.bodyParser()); | ||
app.use(express.methodOverride()); | ||
app.use(app.router); | ||
app.use(logErrors); | ||
app.use(clientErrorHandler); | ||
app.use(errorHandler); | ||
|
||
function logErrors(err, req, res, next) { | ||
console.error(err.stack); | ||
next(err); | ||
} | ||
|
||
function clientErrorHandler(err, req, res, next) { | ||
if (req.xhr) { | ||
res.send(500, { error: 'Something blew up!' }); | ||
} else { | ||
function logErrors(err, req, res, next) { | ||
console.error(err.stack); | ||
next(err); | ||
} | ||
} | ||
|
||
function errorHandler(err, req, res, next) { | ||
res.status(500); | ||
res.render('error', { error: err }); | ||
} | ||
function clientErrorHandler(err, req, res, next) { | ||
if (req.xhr) { | ||
res.send(500, { error: 'Something blew up!' }); | ||
} else { | ||
next(err); | ||
} | ||
} | ||
|
||
function errorHandler(err, req, res, next) { | ||
res.status(500); | ||
res.render('error', { error: err }); | ||
} | ||
|
||
app.get('/info', function(req, res){ | ||
res.send(stats.all()); | ||
}); | ||
app.get('/info', function(req, res){ | ||
res.send({stats: stats.all(), config: config}); | ||
}); | ||
|
||
app.listen(3000); | ||
console.log('Listening on port 3000'); | ||
app.listen(3000); | ||
console.log('Listening on port 3000'); | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters