| Index: server/internal/logdog/service/service.go
|
| diff --git a/server/internal/logdog/service/service.go b/server/internal/logdog/service/service.go
|
| index d4b31a0631fe14cf8ed52d7b73043b7ceb48eb6d..bf1c4d581e0d7399d1cc40dfc99a8ea48c66f93c 100644
|
| --- a/server/internal/logdog/service/service.go
|
| +++ b/server/internal/logdog/service/service.go
|
| @@ -56,6 +56,7 @@ type Service struct {
|
| coordinatorInsecure bool
|
| storageCredentialJSONPath string
|
| cpuProfilePath string
|
| + heapProfilePath string
|
|
|
| coord logdog.ServicesClient
|
| config *config.Manager
|
| @@ -99,6 +100,27 @@ func (s *Service) runImpl(c context.Context, f func(context.Context) error) erro
|
| defer pprof.StopCPUProfile()
|
| }
|
|
|
| + if p := s.heapProfilePath; p != "" {
|
| + defer func() {
|
| + fd, err := os.Create(p)
|
| + if err != nil {
|
| + log.Fields{
|
| + log.ErrorKey: err,
|
| + "path": p,
|
| + }.Warningf(c, "Failed to create heap profile output file.")
|
| + return
|
| + }
|
| + defer fd.Close()
|
| +
|
| + if err := pprof.WriteHeapProfile(fd); err != nil {
|
| + log.Fields{
|
| + log.ErrorKey: err,
|
| + "path": p,
|
| + }.Warningf(c, "Failed to write heap profile.")
|
| + }
|
| + }()
|
| + }
|
| +
|
| // Configure our signal handler. It will listen for terminating signals and
|
| // issue a shutdown signal if one is received.
|
| signalC := make(chan os.Signal)
|
| @@ -161,6 +183,8 @@ func (s *Service) addFlags(c context.Context, fs *flag.FlagSet) {
|
| "If supplied, the path of a JSON credential file to load and use for storage operations.")
|
| fs.StringVar(&s.cpuProfilePath, "cpu-profile-path", "",
|
| "If supplied, enable CPU profiling and write the profile here.")
|
| + fs.StringVar(&s.heapProfilePath, "heap-profile-path", "",
|
| + "If supplied, enable CPU profiling and write the profile here.")
|
| }
|
|
|
| func (s *Service) initCoordinatorClient(c context.Context) (logdog.ServicesClient, error) {
|
|
|