1
0
mirror of https://github.com/go-micro/go-micro.git synced 2025-06-18 22:17:44 +02:00

fixing mem.pprof issue: (#2198)

parsing profile: concatenated profiles detected
fixing web service not start profile issue
fixing no default profile options issue
This commit is contained in:
Johnson C
2021-08-04 16:39:01 +08:00
committed by GitHub
parent c3107e6843
commit 3e0411a3f6
3 changed files with 39 additions and 40 deletions

View File

@ -8,6 +8,7 @@ import (
"os"
"os/signal"
"path/filepath"
"runtime"
"strings"
"sync"
"time"
@ -445,6 +446,23 @@ func (s *service) Run() error {
return err
}
// start the profiler
if s.opts.Service.Options().Profile != nil {
// to view mutex contention
runtime.SetMutexProfileFraction(5)
// to view blocking profile
runtime.SetBlockProfileRate(1)
if err := s.opts.Service.Options().Profile.Start(); err != nil {
return err
}
defer func() {
if err := s.opts.Service.Options().Profile.Stop(); err != nil {
logger.Error(err)
}
}()
}
if err := s.register(); err != nil {
return err
}