lib/suture: Use ServeBackground to start main supervisor (#7626)

This commit is contained in:
Simon Frei
2021-05-10 16:50:45 +02:00
committed by GitHub
parent eb178caf3a
commit 6e662dc9fc
3 changed files with 7 additions and 4 deletions
+4 -3
View File
@@ -110,7 +110,8 @@ func (a *App) Start() error {
a.stopped = make(chan struct{})
ctx, cancel := context.WithCancel(context.Background())
a.mainServiceCancel = cancel
go a.run(ctx)
errChan := a.mainService.ServeBackground(ctx)
go a.wait(errChan)
if err := a.startup(); err != nil {
a.stopWithErr(svcutil.ExitError, err)
@@ -334,8 +335,8 @@ func (a *App) startup() error {
return nil
}
func (a *App) run(ctx context.Context) {
err := a.mainService.Serve(ctx)
func (a *App) wait(errChan <-chan error) {
err := <-errChan
a.handleMainServiceError(err)
done := make(chan struct{})