mirror of
https://github.com/status-im/go-waku.git
synced 2025-02-03 01:14:01 +00:00
chore_: log on panic
This commit is contained in:
parent
37f936d747
commit
15ad28cfc8
@ -356,6 +356,7 @@ func Execute(options NodeOptions) error {
|
||||
|
||||
for _, n := range options.StaticNodes {
|
||||
go func(ctx context.Context, node multiaddr.Multiaddr) {
|
||||
defer utils.LogOnPanic()
|
||||
ctx, cancel := context.WithTimeout(ctx, dialTimeout)
|
||||
defer cancel()
|
||||
err = wakuNode.DialPeerWithMultiAddress(ctx, node)
|
||||
|
@ -9,6 +9,7 @@ import (
|
||||
wprotocol "github.com/waku-org/go-waku/waku/v2/protocol"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/relay"
|
||||
"github.com/waku-org/go-waku/waku/v2/rendezvous"
|
||||
"github.com/waku-org/go-waku/waku/v2/utils"
|
||||
)
|
||||
|
||||
func handleRelayTopics(ctx context.Context, wg *sync.WaitGroup, wakuNode *node.WakuNode, pubSubTopicMap map[string][]string) error {
|
||||
@ -25,6 +26,7 @@ func handleRelayTopics(ctx context.Context, wg *sync.WaitGroup, wakuNode *node.W
|
||||
|
||||
wg.Add(1)
|
||||
go func(nodeTopic string) {
|
||||
defer utils.LogOnPanic()
|
||||
t := time.NewTicker(rendezvous.RegisterDefaultTTL)
|
||||
defer t.Stop()
|
||||
defer wg.Done()
|
||||
@ -42,6 +44,7 @@ func handleRelayTopics(ctx context.Context, wg *sync.WaitGroup, wakuNode *node.W
|
||||
|
||||
wg.Add(1)
|
||||
go func(nodeTopic string) {
|
||||
defer utils.LogOnPanic()
|
||||
defer wg.Done()
|
||||
desiredOutDegree := wakuNode.Relay().Params().D
|
||||
t := time.NewTicker(7 * time.Second)
|
||||
|
@ -14,6 +14,7 @@ import (
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/filter"
|
||||
"go.uber.org/zap"
|
||||
"github.com/waku-org/go-waku/waku/v2/utils"
|
||||
)
|
||||
|
||||
const filterV2Subscriptions = "/filter/v2/subscriptions"
|
||||
@ -32,6 +33,7 @@ type FilterService struct {
|
||||
|
||||
// Start starts the RelayService
|
||||
func (s *FilterService) Start(ctx context.Context) {
|
||||
defer utils.LogOnPanic()
|
||||
|
||||
for _, sub := range s.node.FilterLightnode().Subscriptions() {
|
||||
s.cache.subscribe(sub.ContentFilter)
|
||||
|
@ -10,6 +10,7 @@ import (
|
||||
"github.com/go-chi/chi/v5/middleware"
|
||||
"github.com/waku-org/go-waku/waku/v2/node"
|
||||
"go.uber.org/zap"
|
||||
"github.com/waku-org/go-waku/waku/v2/utils"
|
||||
)
|
||||
|
||||
type WakuRest struct {
|
||||
@ -93,6 +94,7 @@ func (r *WakuRest) Start(ctx context.Context, wg *sync.WaitGroup) {
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
_ = r.server.ListenAndServe()
|
||||
}()
|
||||
r.log.Info("server started", zap.String("addr", r.server.Addr))
|
||||
|
@ -410,6 +410,7 @@ func WaitForMsg(t *testing.T, timeout time.Duration, wg *sync.WaitGroup, ch chan
|
||||
wg.Add(1)
|
||||
log := utils.Logger()
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
defer wg.Done()
|
||||
select {
|
||||
case env := <-ch:
|
||||
@ -425,6 +426,7 @@ func WaitForMsg(t *testing.T, timeout time.Duration, wg *sync.WaitGroup, ch chan
|
||||
func WaitForTimeout(t *testing.T, ctx context.Context, timeout time.Duration, wg *sync.WaitGroup, ch chan *protocol.Envelope) {
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
defer wg.Done()
|
||||
select {
|
||||
case _, ok := <-ch:
|
||||
|
@ -8,6 +8,7 @@ import (
|
||||
"github.com/prometheus/client_golang/prometheus/promhttp"
|
||||
"go.opencensus.io/plugin/ochttp"
|
||||
"go.uber.org/zap"
|
||||
"github.com/waku-org/go-waku/waku/v2/utils"
|
||||
)
|
||||
|
||||
// Server runs and controls a HTTP pprof interface.
|
||||
@ -43,6 +44,7 @@ func NewMetricsServer(address string, port int, log *zap.Logger) *Server {
|
||||
|
||||
// Start executes the HTTP server in the background.
|
||||
func (p *Server) Start() {
|
||||
defer utils.LogOnPanic()
|
||||
p.log.Info("server started ", zap.Error(p.server.ListenAndServe()))
|
||||
}
|
||||
|
||||
|
@ -19,6 +19,7 @@ import (
|
||||
"github.com/libp2p/go-libp2p/p2p/protocol/ping"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/store"
|
||||
"go.uber.org/zap"
|
||||
"github.com/waku-org/go-waku/waku/v2/utils"
|
||||
)
|
||||
|
||||
const defaultBackoff = 10 * time.Second
|
||||
@ -190,6 +191,7 @@ func (m *StorenodeCycle) getAvailableStorenodesSortedByRTT(ctx context.Context,
|
||||
for _, storenode := range allStorenodes {
|
||||
availableStorenodesWg.Add(1)
|
||||
go func(peerID peer.ID) {
|
||||
defer utils.LogOnPanic()
|
||||
defer availableStorenodesWg.Done()
|
||||
ctx, cancel := context.WithTimeout(ctx, 4*time.Second)
|
||||
defer cancel()
|
||||
@ -365,6 +367,8 @@ func (m *StorenodeCycle) penalizeStorenode(id peer.ID) {
|
||||
}
|
||||
|
||||
func (m *StorenodeCycle) verifyStorenodeStatus(ctx context.Context) {
|
||||
defer utils.LogOnPanic()
|
||||
|
||||
ticker := time.NewTicker(storenodeVerificationInterval)
|
||||
defer ticker.Stop()
|
||||
|
||||
@ -421,6 +425,7 @@ func (m *StorenodeCycle) WaitForAvailableStoreNode(ctx context.Context, timeout
|
||||
wg := sync.WaitGroup{}
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
defer wg.Done()
|
||||
for !m.IsStorenodeAvailable(m.activeStorenode) {
|
||||
select {
|
||||
@ -442,6 +447,7 @@ func (m *StorenodeCycle) WaitForAvailableStoreNode(ctx context.Context, timeout
|
||||
func waitForWaitGroup(wg *sync.WaitGroup) <-chan struct{} {
|
||||
ch := make(chan struct{})
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
wg.Wait()
|
||||
close(ch)
|
||||
}()
|
||||
|
@ -13,6 +13,7 @@ import (
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol"
|
||||
"github.com/waku-org/go-waku/waku/v2/protocol/store"
|
||||
"go.uber.org/zap"
|
||||
"github.com/waku-org/go-waku/waku/v2/utils"
|
||||
)
|
||||
|
||||
const maxTopicsPerRequest int = 10
|
||||
@ -81,6 +82,7 @@ func (hr *HistoryRetriever) Query(
|
||||
// Producer
|
||||
wg.Add(1)
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
defer func() {
|
||||
logger.Debug("mailserver batch producer complete")
|
||||
wg.Done()
|
||||
@ -117,6 +119,7 @@ func (hr *HistoryRetriever) Query(
|
||||
}
|
||||
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
workWg.Wait()
|
||||
workCompleteCh <- struct{}{}
|
||||
}()
|
||||
@ -152,6 +155,7 @@ loop:
|
||||
|
||||
semaphore <- struct{}{}
|
||||
go func(w work) { // Consumer
|
||||
defer utils.LogOnPanic()
|
||||
defer func() {
|
||||
workWg.Done()
|
||||
<-semaphore
|
||||
@ -227,6 +231,7 @@ func (hr *HistoryRetriever) createMessagesRequest(
|
||||
})
|
||||
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
storeCursor, envelopesCount, err = hr.requestStoreMessages(ctx, peerID, criteria, cursor, limit, processEnvelopes)
|
||||
resultCh <- struct {
|
||||
storeCursor []byte
|
||||
@ -243,6 +248,7 @@ func (hr *HistoryRetriever) createMessagesRequest(
|
||||
}
|
||||
} else {
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
_, _, err = hr.requestStoreMessages(ctx, peerID, criteria, cursor, limit, false)
|
||||
if err != nil {
|
||||
logger.Error("failed to request store messages", zap.Error(err))
|
||||
|
@ -189,6 +189,7 @@ func (s *FilterTestSuite) waitForMsgFromChan(msg *WakuMsg, ch chan *protocol.Env
|
||||
s.wg.Add(1)
|
||||
var msgFound = false
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
defer s.wg.Done()
|
||||
select {
|
||||
case env := <-ch:
|
||||
@ -233,6 +234,7 @@ func (s *FilterTestSuite) waitForMessages(msgs []WakuMsg) {
|
||||
s.Log.Info("Existing subscriptions ", zap.String("count", strconv.Itoa(len(subs))))
|
||||
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
defer s.wg.Done()
|
||||
for _, sub := range subs {
|
||||
s.Log.Info("Looking at ", zap.String("pubSubTopic", sub.ContentFilter.PubsubTopic))
|
||||
@ -275,6 +277,7 @@ func (s *FilterTestSuite) waitForTimeout(msg *WakuMsg) {
|
||||
func (s *FilterTestSuite) waitForTimeoutFromChan(msg *WakuMsg, ch chan *protocol.Envelope) {
|
||||
s.wg.Add(1)
|
||||
go func() {
|
||||
defer utils.LogOnPanic()
|
||||
defer s.wg.Done()
|
||||
select {
|
||||
case env, ok := <-ch:
|
||||
|
Loading…
x
Reference in New Issue
Block a user