From 7498f864730ee8d6056bbc19b8bcb8311439a677 Mon Sep 17 00:00:00 2001 From: Aleksei Pleshakov Date: Fri, 22 Nov 2024 17:28:31 +0100 Subject: [PATCH] metrics server, init logs --- cmd/ydbcp/config.yaml | 6 ++++++ cmd/ydbcp/main.go | 14 ++++++++++++++ local_config.yaml | 4 ++++ 3 files changed, 24 insertions(+) diff --git a/cmd/ydbcp/config.yaml b/cmd/ydbcp/config.yaml index 2217a9ec..7f08402f 100644 --- a/cmd/ydbcp/config.yaml +++ b/cmd/ydbcp/config.yaml @@ -30,3 +30,9 @@ grpc_server: bind_port: 50051 tls_certificate_path: path/to/tls.crt tls_key_path: path/to/tls.key + +metrics_server: + bind_port: 9090 + bind_address: 127.0.0.1 + #tls_certificate_path: path/to/tls.crt + #tls_key_path: path/to/tls.key diff --git a/cmd/ydbcp/main.go b/cmd/ydbcp/main.go index 5d74cd8a..59bfb358 100644 --- a/cmd/ydbcp/main.go +++ b/cmd/ydbcp/main.go @@ -80,17 +80,21 @@ func main() { ) } metrics := metrics.NewMetricsRegistry(ctx, &wg, &configInstance.MetricsServer) + xlog.Info(ctx, "Initialized metrics registry") server, err := server.NewServer(&configInstance.GRPCServer) if err != nil { xlog.Error(ctx, "failed to initialize GRPC server", zap.Error(err)) os.Exit(1) } + xlog.Info(ctx, "created GRPC server") dbConnector, err := db.NewYdbConnector(ctx, configInstance.DBConnection) if err != nil { xlog.Error(ctx, "Error init DBConnector", zap.Error(err)) os.Exit(1) } + xlog.Info(ctx, "connected to YDBCP database") + defer dbConnector.Close(ctx) clientConnector := client.NewClientYdbConnector(configInstance.ClientConnection) s3Connector, err := s3.NewS3Connector(configInstance.S3) @@ -98,6 +102,7 @@ func main() { xlog.Error(ctx, "Error init S3Connector", zap.Error(err)) os.Exit(1) } + xlog.Info(ctx, "connected to YDBCP S3 storage") var authProvider ap.AuthProvider if len(configInstance.Auth.PluginPath) == 0 { authProvider, err = auth.NewDummyAuthProvider(ctx) @@ -113,6 +118,7 @@ func main() { xlog.Error(ctx, "Error finish auth provider", zap.Error(err)) } }() + xlog.Info(ctx, "Initialized AuthProvider") backup.NewBackupService( dbConnector, @@ -130,6 +136,8 @@ func main() { os.Exit(1) } + xlog.Info(ctx, "Registered services and started GRPC server") + handlersRegistry := processor.NewOperationHandlerRegistry() if err := handlersRegistry.Add( types.OperationTypeTB, @@ -174,12 +182,18 @@ func main() { } processor.NewOperationProcessor(ctx, &wg, dbConnector, handlersRegistry, metrics) + xlog.Info(ctx, "Initialized OperationProcessor") ttl_watcher.NewTtlWatcher(ctx, &wg, dbConnector, queries.NewWriteTableQuery) + xlog.Info(ctx, "Created TtlWatcher") backupScheduleHandler := handlers.NewBackupScheduleHandler( queries.NewWriteTableQuery, clockwork.NewRealClock(), metrics, ) + schedule_watcher.NewScheduleWatcher(ctx, &wg, dbConnector, backupScheduleHandler) + + xlog.Info(ctx, "Created ScheduleWatcher") + xlog.Info(ctx, "YDBCP started") wg.Add(1) go func() { diff --git a/local_config.yaml b/local_config.yaml index 1faddde5..418b6b56 100644 --- a/local_config.yaml +++ b/local_config.yaml @@ -24,3 +24,7 @@ s3: grpc_server: bind_port: 50051 log_level: INFO + +metrics_server: + bind_address: 127.0.0.1 + bind_port: 9090 \ No newline at end of file