🔨 开启 pprof、优化 agent

This commit is contained in:
naiba
2021-05-10 18:04:38 +08:00
parent 842233976b
commit 169865a7e4
8 changed files with 13 additions and 8 deletions

View File

@@ -62,10 +62,9 @@ func doSelfUpdate() {
return
}
if latest.Version.Equals(v) {
// latest version is the same as current version. It means current binary is up to date.
println("Current binary is the latest version", version)
println("Current binary is up to date", version)
} else {
println("Successfully updated to version", latest.Version)
println("Upgrade successfully", latest.Version)
os.Exit(1)
}
}

View File

@@ -7,6 +7,7 @@ import (
"time"
"code.cloudfoundry.org/bytefmt"
"github.com/gin-contrib/pprof"
"github.com/gin-gonic/gin"
"github.com/naiba/nezha/pkg/mygin"
@@ -15,10 +16,11 @@ import (
func ServeWeb(port uint) {
gin.SetMode(gin.ReleaseMode)
r := gin.Default()
if dao.Conf.Debug {
gin.SetMode(gin.DebugMode)
pprof.Register(r)
}
r := gin.Default()
r.Use(mygin.RecordPath)
r.SetFuncMap(template.FuncMap{
"tf": func(t time.Time) string {