Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix: check server start error #3481

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion app.go
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@ package kratos
import (
"context"
"errors"
"fmt"
"os"
"os/signal"
"sync"
Expand Down Expand Up @@ -108,11 +109,15 @@ func (a *App) Run() error {
})
wg.Add(1)
eg.Go(func() error {
wg.Done() // here is to ensure server start has begun running before register, so defer is not needed
defer wg.Done() // should call Done after Start since we need to capture any potential error
return server.Start(NewContext(a.opts.ctx, a))
})
}
wg.Wait()
if err = ctx.Err(); err != nil {
return fmt.Errorf("%w: %w", err, context.Cause(ctx))
}

if a.opts.registrar != nil {
rctx, rcancel := context.WithTimeout(ctx, a.opts.registrarTimeout)
defer rcancel()
Expand Down