use messina for logging in production.
This commit is contained in:
Родитель
d849290db6
Коммит
9cb7351c3f
|
@ -138,6 +138,10 @@ If `DEBUG` is defined in the environment (even as an empty string),
|
|||
then some assets will be always be regenerated on-the-fly, which
|
||||
is useful for debugging.
|
||||
|
||||
If `DEBUG` is *not* defined then [messina][] will be used for logging
|
||||
and you may want to set its `GRAYLOG_*` environment variables
|
||||
accordingly.
|
||||
|
||||
## Running Tests
|
||||
|
||||
To run the test suite, run `npm test`.
|
||||
|
@ -154,3 +158,4 @@ There's also a manual test suite at http://localhost:3000/manual-test/.
|
|||
[permission]: http://blitline.com/docs/s3_permissions
|
||||
[Discourse]: http://discourse.org/
|
||||
[Webmaker Discourse]: http://discourse.webmaker.org/t/webmaker-screenshots/331
|
||||
[messina]: https://www.npmjs.com/package/messina
|
||||
|
|
23
app.js
23
app.js
|
@ -1,5 +1,6 @@
|
|||
var express = require('express');
|
||||
var morgan = require('morgan');
|
||||
var messina = require('messina');
|
||||
var browserify = require('browserify');
|
||||
var bodyParser = require('body-parser');
|
||||
|
||||
|
@ -14,15 +15,24 @@ var bundlejs;
|
|||
var screenshotConfig = new ScreenshotConfig();
|
||||
var redisCache = new RedisCache(process.env.REDIS_URL ||
|
||||
process.env.REDISTOGO_URL);
|
||||
var log = messina('webmaker-screenshot');
|
||||
var app = express();
|
||||
|
||||
if (!DEBUG) log.catchFatal();
|
||||
|
||||
redisCache.client.on('error', function(err) {
|
||||
// Hopefully we've just temporarily lost connection to the
|
||||
// server.
|
||||
console.log(err);
|
||||
if (DEBUG)
|
||||
console.log(err.message);
|
||||
else
|
||||
log.error(err.message);
|
||||
});
|
||||
|
||||
if (DEBUG) app.use(morgan('dev'));
|
||||
if (DEBUG)
|
||||
app.use(morgan('dev'));
|
||||
else
|
||||
app.use(log.middleware());
|
||||
|
||||
app.use(bodyParser.json());
|
||||
|
||||
|
@ -69,6 +79,15 @@ app.use(function(req, res, next) {
|
|||
|
||||
app.use(express.static(__dirname + '/static'));
|
||||
|
||||
app.use(function(err, req, res, next) {
|
||||
if (DEBUG) {
|
||||
console.log(err.stack);
|
||||
return res.type("text/plain").status(500).send(err.stack);
|
||||
} else
|
||||
log.error(err.stack);
|
||||
res.status(500).send("Internal Server Error");
|
||||
});
|
||||
|
||||
app.listen(PORT, function() {
|
||||
console.log('listening on port ' + PORT);
|
||||
});
|
||||
|
|
|
@ -4,12 +4,13 @@
|
|||
"description": "Take thumbnail screenshots of Webmaker makes.",
|
||||
"dependencies": {
|
||||
"body-parser": "~1.2.0",
|
||||
"redis": "0.12.1",
|
||||
"underscore": "1.7.0",
|
||||
"browserify": "8.1.1",
|
||||
"express": "~4.2.0",
|
||||
"messina": "^0.1.2",
|
||||
"morgan": "^1.5.1",
|
||||
"redis": "0.12.1",
|
||||
"request": "2.34.0",
|
||||
"morgan": "^1.5.1"
|
||||
"underscore": "1.7.0"
|
||||
},
|
||||
"devDependencies": {
|
||||
"nock": "0.57.0",
|
||||
|
|
Загрузка…
Ссылка в новой задаче