improve (profiling): create a flag to enable profiling

This commit is contained in:
Mickael KERJEAN
2018-11-19 14:27:41 +11:00
parent edd6ba9d12
commit 0ed846f5f3
2 changed files with 20 additions and 4 deletions
+3 -3
View File
@@ -173,21 +173,21 @@ export const onUpload = function(path, e){
</h2>
<div className="stats_content">
{
currents.map((process, i) => {
currents.slice(0, 1000).map((process, i) => {
return (
<div onClick={() => this.emphasis(process.path)} className="current_color" key={i}>{process.path.replace(/\//, '')}</div>
);
})
}
{
processes.slice(0, 2000).map((process, i) => {
processes.slice(0, 1000).map((process, i) => {
return (
<div onClick={() => this.emphasis(process.path)} className="todo_color" key={i}>{process.path.replace(/\//, '')}</div>
);
})
}
{
failed.slice(0, 200).map((process, i) => {
failed.slice(0, 500).map((process, i) => {
return (
<div onClick={() => this.emphasis(process.path)} className="error_color" key={i}>{process.path}</div>
);
+17 -1
View File
@@ -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")