go services: fix bug that starts profiling 3 times

Signed-off-by: Ahmet Alp Balkan <ahmetb@google.com>
This commit is contained in:
Ahmet Alp Balkan 2018-07-17 21:33:49 -07:00
parent ab32b5f954
commit b943dda1b7
4 changed files with 15 additions and 5 deletions

View file

@ -95,6 +95,9 @@ func initProfiling(service, version string) {
// ProjectID: "my-project",
}); err != nil {
log.Printf("warn: failed to start profiler: %+v", err)
} else {
log.Print("started stackdriver profiler")
return
}
d := time.Second * 10 * time.Duration(i)
log.Printf("sleeping %v to retry initializing stackdriver profiler", d)

View file

@ -145,6 +145,9 @@ func initProfiling(log logrus.FieldLogger, service, version string) {
// ProjectID: "my-project",
}); err != nil {
log.Warnf("warn: failed to start profiler: %+v", err)
} else {
log.Info("started stackdriver profiler")
return
}
d := time.Second * 10 * time.Duration(i)
log.Debugf("sleeping %v to retry initializing stackdriver profiler", d)

View file

@ -90,12 +90,13 @@ func initProfiling(service, version string) {
// ProjectID: "my-project",
}); err != nil {
log.Printf("warn: failed to start profiler: %+v", err)
d := time.Second * 10 * time.Duration(i)
log.Printf("sleeping %v to retry initializing stackdriver profiler", d)
time.Sleep(d)
continue
} else {
log.Print("started stackdriver profiler")
return
}
return
d := time.Second * 10 * time.Duration(i)
log.Debugf("sleeping %v to retry initializing stackdriver profiler", d)
time.Sleep(d)
}
log.Printf("warning: could not initialize stackdriver profiler after retrying, giving up")
}

View file

@ -120,6 +120,9 @@ func initProfiling(service, version string) {
// ProjectID: "my-project",
}); err != nil {
log.Printf("warn: failed to start profiler: %+v", err)
} else {
log.Print("started stackdriver profiler")
return
}
d := time.Second * 10 * time.Duration(i)
log.Printf("sleeping %v to retry initializing stackdriver profiler", d)