Skip to content
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
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Will the defer statement be executed when the server is blocked?

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