Procházet zdrojové kódy

Add profiling end point

James Allen před 9 roky
rodič
revize
3cf58083d4
2 změnil soubory, kde provedl 12 přidání a 14 odebrání
  1. 10 13
      services/chat/app/coffee/server.coffee
  2. 2 1
      services/chat/package.json

+ 10 - 13
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

+ 2 - 1
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",