From 3cf58083d411485b813524bbbde7ef553d0d4378 Mon Sep 17 00:00:00 2001 From: James Allen Date: Wed, 18 Jan 2017 14:34:28 +0100 Subject: [PATCH] Add profiling end point --- services/chat/app/coffee/server.coffee | 23 ++++++++++------------- services/chat/package.json | 3 ++- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/services/chat/app/coffee/server.coffee b/services/chat/app/coffee/server.coffee index dfac228bdd..7287a90902 100644 --- a/services/chat/app/coffee/server.coffee +++ b/services/chat/app/coffee/server.coffee @@ -12,7 +12,6 @@ metrics.mongodb.monitor(Path.resolve(__dirname + "/../../node_modules/mongojs/no app.use express.bodyParser() app.use metrics.http.monitor(logger) -Router.route(app) if (app.get 'env') == 'development' console.log "Development Enviroment" @@ -22,19 +21,17 @@ if (app.get 'env') == 'production' console.log "Production Enviroment" app.use express.logger() app.use express.errorHandler() + +profiler = require "v8-profiler" +app.get "/profile", (req, res) -> + time = parseInt(req.query.time || "1000") + profiler.startProfiling("test") + setTimeout () -> + profile = profiler.stopProfiling("test") + res.json(profile) + , time - - -mountPoint = "/chat" -app.use (req, res, next) -> - - if req.url.slice(0, mountPoint.length) == mountPoint - req.url = req.url.slice(mountPoint.length) - next() - else - res.send(404) - -app.use(express.static(__dirname + "/../../public/build")) +Router.route(app) module.exports = { server: server diff --git a/services/chat/package.json b/services/chat/package.json index d30b905039..bb5bd66944 100644 --- a/services/chat/package.json +++ b/services/chat/package.json @@ -15,7 +15,8 @@ "mongojs": "^2.4.0", "redis": "~0.10.1", "request": "^2.79.0", - "settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0" + "settings-sharelatex": "git+https://github.com/sharelatex/settings-sharelatex.git#v1.0.0", + "v8-profiler": "^5.6.5" }, "devDependencies": { "bunyan": "^1.0.0",