diff --git a/cmd/ipfs/daemon.go b/cmd/ipfs/daemon.go index d8461c9a8..049d68e4e 100644 --- a/cmd/ipfs/daemon.go +++ b/cmd/ipfs/daemon.go @@ -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