Storagenode logs and config improvements (#1075)
* Add more info to SN logs * remove config-dir from user config * add output where config was stored * add message for successful connection * fix linter * remove storage.path from user config * resolve config path * move success message to info * log improvements
This commit is contained in:
parent
9dbb6a101d
commit
f9abb4584c
@ -107,6 +107,10 @@ func init() {
|
||||
}
|
||||
|
||||
rootCmd.PersistentFlags().StringVar(&confDir, "config-dir", defaultConfDir, "main directory for storagenode configuration")
|
||||
err := rootCmd.PersistentFlags().SetAnnotation("config-dir", "setup", []string{"true"})
|
||||
if err != nil {
|
||||
zap.S().Error("Failed to set 'setup' annotation for 'config-dir'")
|
||||
}
|
||||
|
||||
defaultDiagDir = filepath.Join(defaultConfDir, "storage")
|
||||
rootCmd.AddCommand(runCmd)
|
||||
|
@ -112,11 +112,15 @@ func (c Config) Run(ctx context.Context, server *provider.Provider,
|
||||
go func() {
|
||||
if err = kad.Bootstrap(ctx); err != nil {
|
||||
logger.Error("Failed to bootstrap Kademlia", zap.Any("ID", server.Identity().ID))
|
||||
} else {
|
||||
logger.Sugar().Infof("Successfully connected to Kademlia bootstrap node %s", c.BootstrapAddr)
|
||||
}
|
||||
}()
|
||||
|
||||
pb.RegisterNodesServer(server.GRPC(), node.NewServer(logger, kad))
|
||||
|
||||
zap.S().Infof("Kademlia external address: %s", addr)
|
||||
|
||||
zap.S().Warn("Once the Peer refactor is done, the kad inspector needs to be registered on a " +
|
||||
"gRPC server that only listens on localhost")
|
||||
// TODO: register on a private rpc server
|
||||
|
@ -47,6 +47,8 @@ func (server *Server) Query(ctx context.Context, req *pb.QueryRequest) (*pb.Quer
|
||||
if err != nil {
|
||||
server.log.Error("could not respond to connection success", zap.Error(err))
|
||||
}
|
||||
|
||||
server.log.Sugar().Infof("Successfully connected with %s", req.Sender.Address.Address)
|
||||
}
|
||||
|
||||
nodes, err := rt.FindNear(req.Target.Id, int(req.Limit))
|
||||
|
@ -28,7 +28,7 @@ var (
|
||||
|
||||
// Config contains everything necessary for a server
|
||||
type Config struct {
|
||||
Path string `user:"true" help:"path to store data in" default:"$CONFDIR/storage"`
|
||||
Path string `help:"path to store data in" default:"$CONFDIR/storage"`
|
||||
AllocatedDiskSpace memory.Size `user:"true" help:"total allocated disk space in bytes" default:"1TiB"`
|
||||
AllocatedBandwidth memory.Size `user:"true" help:"total allocated bandwidth in bytes" default:"500GiB"`
|
||||
KBucketRefreshInterval time.Duration `help:"how frequently Kademlia bucket should be refreshed with node stats" default:"1h0m0s"`
|
||||
|
@ -106,7 +106,13 @@ func saveConfig(flagset *pflag.FlagSet, outfile string, overrides map[string]int
|
||||
fmt.Fprintf(w, "%s\n", value)
|
||||
}
|
||||
}
|
||||
return ioutil.WriteFile(outfile, []byte(sb.String()), os.FileMode(0644))
|
||||
|
||||
err := ioutil.WriteFile(outfile, []byte(sb.String()), os.FileMode(0644))
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
fmt.Println("Configuration saved to:", outfile)
|
||||
return nil
|
||||
}
|
||||
|
||||
func readBoolAnnotation(flag *pflag.Flag, key string) bool {
|
||||
@ -194,7 +200,15 @@ func cleanup(cmd *cobra.Command) {
|
||||
return err
|
||||
}
|
||||
|
||||
logger.Sugar().Debug("Configuration loaded from: ", vip.ConfigFileUsed())
|
||||
if vip.ConfigFileUsed() != "" {
|
||||
path, err := filepath.Abs(vip.ConfigFileUsed())
|
||||
if err != nil {
|
||||
path = vip.ConfigFileUsed()
|
||||
logger.Debug("unable to resolve path", zap.Error(err))
|
||||
}
|
||||
|
||||
logger.Sugar().Info("Configuration loaded from: ", path)
|
||||
}
|
||||
|
||||
defer func() { _ = logger.Sync() }()
|
||||
defer zap.ReplaceGlobals(logger)()
|
||||
|
@ -53,6 +53,6 @@ func (sc Config) Run(ctx context.Context,
|
||||
}
|
||||
defer func() { _ = s.Close() }()
|
||||
|
||||
zap.S().Infof("Node %s started", s.Identity().ID)
|
||||
zap.S().Infof("Node %s started on %s", s.Identity().ID, sc.Address)
|
||||
return s.Run(ctx)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user