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:
@ -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
|
||||
}
|
||||
|
Reference in New Issue
Block a user