mirror of
https://github.com/TryGhost/Ghost.git
synced 2025-01-20 22:42:53 -05:00
Debug: LocalStorage response time
no issue
This commit is contained in:
parent
41c9db30b5
commit
78ac98ee27
1 changed files with 14 additions and 1 deletions
|
@ -9,10 +9,12 @@ var serveStatic = require('express').static,
|
||||||
fs = require('fs-extra'),
|
fs = require('fs-extra'),
|
||||||
path = require('path'),
|
path = require('path'),
|
||||||
Promise = require('bluebird'),
|
Promise = require('bluebird'),
|
||||||
|
moment = require('moment'),
|
||||||
config = require('../../config'),
|
config = require('../../config'),
|
||||||
errors = require('../../errors'),
|
errors = require('../../errors'),
|
||||||
i18n = require('../../i18n'),
|
i18n = require('../../i18n'),
|
||||||
utils = require('../../utils'),
|
utils = require('../../utils'),
|
||||||
|
logging = require('../../logging'),
|
||||||
StorageBase = require('ghost-storage-base');
|
StorageBase = require('ghost-storage-base');
|
||||||
|
|
||||||
class LocalFileStore extends StorageBase {
|
class LocalFileStore extends StorageBase {
|
||||||
|
@ -81,7 +83,18 @@ class LocalFileStore extends StorageBase {
|
||||||
var self = this;
|
var self = this;
|
||||||
|
|
||||||
return function serveStaticContent(req, res, next) {
|
return function serveStaticContent(req, res, next) {
|
||||||
return serveStatic(self.storagePath, {maxAge: utils.ONE_YEAR_MS, fallthrough: false})(req, res, function (err) {
|
var startedAtMoment = moment();
|
||||||
|
|
||||||
|
return serveStatic(
|
||||||
|
self.storagePath,
|
||||||
|
{
|
||||||
|
maxAge: utils.ONE_YEAR_MS,
|
||||||
|
fallthrough: false,
|
||||||
|
onEnd: function onEnd() {
|
||||||
|
logging.info('LocalFileStorage.serve', req.path, moment().diff(startedAtMoment, 'ms') + 'ms');
|
||||||
|
}
|
||||||
|
}
|
||||||
|
)(req, res, function (err) {
|
||||||
if (err) {
|
if (err) {
|
||||||
if (err.statusCode === 404) {
|
if (err.statusCode === 404) {
|
||||||
return next(new errors.NotFoundError({
|
return next(new errors.NotFoundError({
|
||||||
|
|
Loading…
Add table
Reference in a new issue