Skip to content

Commit 43573bb

Browse files
chore: add go stack trace for debug
1 parent 2420e7a commit 43573bb

File tree

4 files changed

+13
-4
lines changed

4 files changed

+13
-4
lines changed

rolling-shutter/eonkeypublisher/eonkeypublisher.go

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ package eonkeypublisher
33
import (
44
"context"
55
"crypto/ecdsa"
6+
"runtime"
67
"time"
78

89
"github.com/ethereum/go-ethereum/accounts/abi/bind"
@@ -67,6 +68,10 @@ func (p *EonKeyPublisher) Start(ctx context.Context, runner service.Runner) erro
6768
case key := <-p.keys:
6869
p.publishIfResponsible(ctx, key)
6970
case <-ctx.Done():
71+
log.Info().Msgf("stopping eon key publisher, due to context cancellation, goroutines: %d", runtime.NumGoroutine())
72+
buf := make([]byte, 1024*1024)
73+
stackSize := runtime.Stack(buf, true)
74+
log.Info().Msgf("stack: %s", string(buf[:stackSize]))
7075
return ctx.Err()
7176
}
7277
}

rolling-shutter/keyper/eonpkhandler.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -66,6 +66,7 @@ func (pkh *eonPubKeyHandler) loop(ctx context.Context) error {
6666
}
6767
select {
6868
case <-ctx.Done():
69+
t.Stop()
6970
return ctx.Err()
7071
case <-t.C:
7172
}

rolling-shutter/keyperimpl/shutterservice/syncmonitor.go

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -26,8 +26,12 @@ func (s *SyncMonitor) Start(ctx context.Context, runner service.Runner) error {
2626
})
2727

2828
runner.Go(func() error {
29-
<-time.After(30 * time.Minute)
30-
return errors.New("explicitly canceling context")
29+
select {
30+
case <-time.After(30 * time.Minute):
31+
return errors.New("explicitly canceling context")
32+
case <-ctx.Done():
33+
return ctx.Err()
34+
}
3135
})
3236

3337
return nil

rolling-shutter/p2p/p2p.go

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -171,8 +171,7 @@ func (p *P2PNode) Run(
171171
runner.Go(func() error {
172172
log.Info().Str("namespace", p.config.DiscoveryNamespace).Msg("starting advertizing discovery node")
173173
util.Advertise(ctx, p.discovery, p.config.DiscoveryNamespace)
174-
<-ctx.Done()
175-
return ctx.Err()
174+
return nil
176175
})
177176
runner.Go(func() error {
178177
return findPeers(ctx, p.host, p.discovery, p.config.DiscoveryNamespace)

0 commit comments

Comments
 (0)