Skip to content
Merged
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
12 changes: 9 additions & 3 deletions server/v2/commands.go
Original file line number Diff line number Diff line change
Expand Up @@ -120,9 +120,15 @@ func createStartCommand[T transaction.Tx](
go func() {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)
sig := <-sigCh
cancelFn()
cmd.Printf("caught %s signal\n", sig.String())
select {
case sig := <-sigCh:
cancelFn()
cmd.Printf("caught %s signal\n", sig.String())
case <-ctx.Done():
// If the root context is canceled (which is likely to happen in tests involving cobra commands),
// don't block waiting for the OS signal before stopping the server.
cancelFn()
}

if err := server.Stop(ctx); err != nil {
cmd.PrintErrln("failed to stop servers:", err)
Expand Down