mirror of
https://github.com/ipfs/kubo.git
synced 2026-03-06 00:38:08 +08:00
feat: print error on bootstrap failure
This will print ERROR to log if daemon running in online mode has no peers after one minute since start.
This commit is contained in:
parent
9c8b1019e5
commit
039e12a2da
@ -12,6 +12,7 @@ import (
|
||||
"runtime"
|
||||
"sort"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
multierror "github.com/hashicorp/go-multierror"
|
||||
|
||||
@ -22,6 +23,7 @@ import (
|
||||
oldcmds "github.com/ipfs/go-ipfs/commands"
|
||||
"github.com/ipfs/go-ipfs/core"
|
||||
commands "github.com/ipfs/go-ipfs/core/commands"
|
||||
"github.com/ipfs/go-ipfs/core/coreapi"
|
||||
corehttp "github.com/ipfs/go-ipfs/core/corehttp"
|
||||
corerepo "github.com/ipfs/go-ipfs/core/corerepo"
|
||||
libp2p "github.com/ipfs/go-ipfs/core/node/libp2p"
|
||||
@ -510,6 +512,23 @@ func daemonFunc(req *cmds.Request, re cmds.ResponseEmitter, env cmds.Environment
|
||||
fmt.Println("(Hit ctrl-c again to force-shutdown the daemon.)")
|
||||
}()
|
||||
|
||||
// Give the user heads up if daemon running in online mode has no peers after 1 minute
|
||||
if !offline {
|
||||
time.AfterFunc(1*time.Minute, func() {
|
||||
ipfs, err := coreapi.NewCoreAPI(node)
|
||||
if err != nil {
|
||||
log.Errorf("failed to access CoreAPI: %v", err)
|
||||
}
|
||||
peers, err := ipfs.Swarm().Peers(cctx.Context())
|
||||
if err != nil {
|
||||
log.Errorf("failed to read swarm peers: %v", err)
|
||||
}
|
||||
if len(peers) == 0 {
|
||||
log.Error("failed to bootstrap (no peers found): consider updating Bootstrap or Peering section of your config")
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
// collect long-running errors and block for shutdown
|
||||
// TODO(cryptix): our fuse currently doesn't follow this pattern for graceful shutdown
|
||||
var errs error
|
||||
|
||||
Loading…
Reference in New Issue
Block a user