Skip to content

Commit

Permalink
metrics server, init logs
Browse files Browse the repository at this point in the history
  • Loading branch information
Aleksei Pleshakov authored and qrort committed Nov 25, 2024
1 parent 055eadc commit 7498f86
Show file tree
Hide file tree
Showing 3 changed files with 24 additions and 0 deletions.
6 changes: 6 additions & 0 deletions cmd/ydbcp/config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -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
14 changes: 14 additions & 0 deletions cmd/ydbcp/main.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,24 +80,29 @@ 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)
if err != nil {
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)
Expand All @@ -113,6 +118,7 @@ func main() {
xlog.Error(ctx, "Error finish auth provider", zap.Error(err))
}
}()
xlog.Info(ctx, "Initialized AuthProvider")

backup.NewBackupService(
dbConnector,
Expand All @@ -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,
Expand Down Expand Up @@ -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() {
Expand Down
4 changes: 4 additions & 0 deletions local_config.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -24,3 +24,7 @@ s3:
grpc_server:
bind_port: 50051
log_level: INFO

metrics_server:
bind_address: 127.0.0.1
bind_port: 9090

0 comments on commit 7498f86

Please sign in to comment.