Skip to content

Commit

Permalink
fix: handle sigterm properly in case genesis is in the future
Browse files Browse the repository at this point in the history
  • Loading branch information
fridrik01 committed Jan 19, 2025
1 parent 395085d commit 0a80791
Showing 1 changed file with 18 additions and 1 deletion.
19 changes: 18 additions & 1 deletion consensus/cometbft/service/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,24 @@ func (s *Service[_]) Start(
return err
}

return s.node.Start()
started := make(chan struct{})

// we start the node in a goroutine since calling Start() can block if genesis
// time is in the future causing us not to handle signals gracefully.
go func() {
err = s.node.Start()
started <- struct{}{}
}()

select {
case <-ctx.Done():
return ctx.Err()
case <-started:
}

close(started)

return err
}

func (s *Service[_]) Stop() error {
Expand Down

0 comments on commit 0a80791

Please sign in to comment.