From 118d462569b926cbec4c0c0f57c08c2eacce4034 Mon Sep 17 00:00:00 2001 From: xhe Date: Wed, 17 Jan 2024 16:35:29 +0800 Subject: [PATCH 1/3] log: print welcom after config init Signed-off-by: xhe --- pkg/server/server.go | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/pkg/server/server.go b/pkg/server/server.go index 63d1fef5..4065668e 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -61,7 +61,6 @@ func NewServer(ctx context.Context, sctx *sctx.Context) (srv *Server, err error) return } srv.LoggerManager.Init(srv.ConfigManager.WatchConfig()) - printInfo(lg) // setup config manager if err = srv.ConfigManager.Init(ctx, lg.Named("config"), sctx.ConfigFile, &sctx.Overlay); err != nil { @@ -70,6 +69,8 @@ func NewServer(ctx context.Context, sctx *sctx.Context) (srv *Server, err error) } cfg := srv.ConfigManager.GetConfig() + printInfo(lg) + // setup metrics srv.MetricsManager.Init(ctx, lg.Named("metrics")) metrics.ServerEventCounter.WithLabelValues(metrics.EventStart).Inc() From 0730f81ae52aff56c613e8734b69c747ef5007a6 Mon Sep 17 00:00:00 2001 From: xhe Date: Thu, 18 Jan 2024 10:30:36 +0800 Subject: [PATCH 2/3] add comments Signed-off-by: xhe --- pkg/server/server.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/server/server.go b/pkg/server/server.go index 4065668e..db23d99a 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -69,6 +69,9 @@ func NewServer(ctx context.Context, sctx *sctx.Context) (srv *Server, err error) } cfg := srv.ConfigManager.GetConfig() + // welcome messages must be printed after initialization of configmager, because + // logfile backended zaplogger is enabled after cfgmgr.Init(..). + // otherwise, printInfo will output to stdout, which can not be redirected to the log file on tiup-cluster. printInfo(lg) // setup metrics From 231c0b866bb1e35cfa318ba5ba16da8f071818ae Mon Sep 17 00:00:00 2001 From: xhe Date: Thu, 18 Jan 2024 11:57:53 +0800 Subject: [PATCH 3/3] Update server.go --- pkg/server/server.go | 3 +++ 1 file changed, 3 insertions(+) diff --git a/pkg/server/server.go b/pkg/server/server.go index db23d99a..0bb2851b 100644 --- a/pkg/server/server.go +++ b/pkg/server/server.go @@ -72,6 +72,9 @@ func NewServer(ctx context.Context, sctx *sctx.Context) (srv *Server, err error) // welcome messages must be printed after initialization of configmager, because // logfile backended zaplogger is enabled after cfgmgr.Init(..). // otherwise, printInfo will output to stdout, which can not be redirected to the log file on tiup-cluster. + // + // TODO: there is a race condition that printInfo and logmgr may concurrently execute: + // logmgr may havenot been initialized with logfile yet printInfo(lg) // setup metrics