From 0ed846f5f3277cd12b281c504a3003be62c730b6 Mon Sep 17 00:00:00 2001 From: Mickael KERJEAN Date: Mon, 19 Nov 2018 14:27:41 +1100 Subject: [PATCH] improve (profiling): create a flag to enable profiling --- client/pages/filespage.helper.js | 6 +++--- server/main.go | 18 +++++++++++++++++- 2 files changed, 20 insertions(+), 4 deletions(-) diff --git a/client/pages/filespage.helper.js b/client/pages/filespage.helper.js index 0a3c5978..24616f9d 100644 --- a/client/pages/filespage.helper.js +++ b/client/pages/filespage.helper.js @@ -173,21 +173,21 @@ export const onUpload = function(path, e){
{ - currents.map((process, i) => { + currents.slice(0, 1000).map((process, i) => { return (
this.emphasis(process.path)} className="current_color" key={i}>{process.path.replace(/\//, '')}
); }) } { - processes.slice(0, 2000).map((process, i) => { + processes.slice(0, 1000).map((process, i) => { return (
this.emphasis(process.path)} className="todo_color" key={i}>{process.path.replace(/\//, '')}
); }) } { - failed.slice(0, 200).map((process, i) => { + failed.slice(0, 500).map((process, i) => { return (
this.emphasis(process.path)} className="error_color" key={i}>{process.path}
); diff --git a/server/main.go b/server/main.go index 8e809da1..a822c445 100644 --- a/server/main.go +++ b/server/main.go @@ -7,6 +7,8 @@ import ( . "github.com/mickael-kerjean/nuage/server/middleware" _ "github.com/mickael-kerjean/nuage/server/plugin" "net/http" + "net/http/pprof" + "os" "strconv" ) @@ -20,6 +22,20 @@ func main() { func Init(a *App) { r := mux.NewRouter() + // Profiling - handy to indentify nasty leaks and/or bugs! + if os.Getenv("DEBUG") == "true" { + r.HandleFunc("/debug/pprof/", pprof.Index) + r.HandleFunc("/debug/pprof/cmdline", pprof.Cmdline) + r.HandleFunc("/debug/pprof/profile", pprof.Profile) + r.HandleFunc("/debug/pprof/symbol", pprof.Symbol) + r.HandleFunc("/debug/pprof/trace", pprof.Trace) + r.Handle("/debug/pprof/goroutine", pprof.Handler("goroutine")) + r.Handle("/debug/pprof/heap", pprof.Handler("heap")) + r.Handle("/debug/pprof/threadcreate", pprof.Handler("threadcreate")) + r.Handle("/debug/pprof/block", pprof.Handler("block")) + r.Handle("/debug/pprof/heap", pprof.Handler("heap")) + } + // API session := r.PathPrefix("/api/session").Subrouter() session.HandleFunc("", APIHandler(SessionGet, *a)).Methods("GET") @@ -44,7 +60,7 @@ func Init(a *App) { // WEBDAV r.PathPrefix("/s/{share}").Handler(CtxInjector(WebdavHandler, *a)) - + // APP r.HandleFunc("/api/config", CtxInjector(ConfigHandler, *a)).Methods("GET") r.PathPrefix("/assets").Handler(StaticHandler(FILE_ASSETS, *a)).Methods("GET")