Skip to content
Merged
Show file tree
Hide file tree
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
4 changes: 2 additions & 2 deletions cmd/akash/cmd/testnetify/testnetify.go
Original file line number Diff line number Diff line change
Expand Up @@ -185,7 +185,7 @@ you want to test the upgrade handler itself.
getCtx := func(svrCtx *sdksrv.Context, block bool) (*errgroup.Group, context.Context) {
g, ctx := errgroup.WithContext(ctx)
// listen for quit signals so the calling parent process can gracefully exit
server.ListenForQuitSignals(g, block, cancelFn, svrCtx.Logger)
server.ListenForQuitSignals(ctx, cancelFn, g, block, svrCtx.Logger)
return g, ctx
}

Expand Down Expand Up @@ -238,7 +238,7 @@ you want to test the upgrade handler itself.
case <-ticker.C:
status, err := cctx.Client.Status(ctx)
if err == nil && status != nil {
if status.SyncInfo.LatestBlockHeight > h+1 {
if status.SyncInfo.LatestBlockHeight > h+2 {
return
}
}
Expand Down
2 changes: 1 addition & 1 deletion cmd/akash/cmd/testnetify/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ func getCtx(sctx *sdksrv.Context, block bool) (*errgroup.Group, context.Context)
ctx, cancelFn := context.WithCancel(context.Background())
g, ctx := errgroup.WithContext(ctx)
// listen for quit signals so the calling parent process can gracefully exit
server.ListenForQuitSignals(g, block, cancelFn, sctx.Logger)
server.ListenForQuitSignals(ctx, cancelFn, g, block, sctx.Logger)

return g, ctx
}
12 changes: 8 additions & 4 deletions util/server/utils.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,15 +16,19 @@ import (
//
// Note, the blocking behavior of this depends on the block argument.
// The caller must ensure the corresponding context derived from the cancelFn is used correctly.
func ListenForQuitSignals(g *errgroup.Group, block bool, cancelFn context.CancelFunc, logger log.Logger) {
func ListenForQuitSignals(ctx context.Context, cancelFn context.CancelFunc, g *errgroup.Group, block bool, logger log.Logger) {
sigCh := make(chan os.Signal, 1)
signal.Notify(sigCh, syscall.SIGINT, syscall.SIGTERM)

f := func() {
sig := <-sigCh
cancelFn()
select {
case sig := <-sigCh:
logger.Info("caught signal", "signal", sig.String())
case <-ctx.Done():
logger.Info("context canceled")
}

logger.Info("caught signal", "signal", sig.String())
cancelFn()
}

if block {
Expand Down
Loading