From 4fc4822696b3e74624b7535ee2bdc1b868b3db7f Mon Sep 17 00:00:00 2001 From: Roman Perekhod Date: Tue, 10 Jun 2025 18:21:49 +0200 Subject: [PATCH] collect the errors from group runner --- ocis-pkg/runner/grouprunner.go | 12 +++++++ ocis-pkg/runner/types.go | 10 ++++++ services/activitylog/pkg/command/server.go | 10 +++--- services/antivirus/pkg/command/server.go | 10 +++--- services/app-provider/pkg/command/server.go | 10 +++--- services/app-registry/pkg/command/server.go | 10 +++--- services/audit/pkg/command/server.go | 10 +++--- services/auth-app/pkg/command/server.go | 10 +++--- services/auth-basic/pkg/command/server.go | 10 +++--- services/auth-bearer/pkg/command/server.go | 10 +++--- services/auth-machine/pkg/command/server.go | 10 +++--- services/auth-service/pkg/command/server.go | 10 +++--- services/clientlog/pkg/command/server.go | 10 +++--- services/collaboration/pkg/command/server.go | 10 +++--- services/eventhistory/pkg/command/server.go | 10 +++--- services/frontend/pkg/command/server.go | 10 +++--- services/gateway/pkg/command/server.go | 10 +++--- services/graph/pkg/command/server.go | 10 +++--- services/groups/pkg/command/server.go | 10 +++--- services/idm/pkg/command/server.go | 10 +++--- services/invitations/pkg/command/server.go | 10 +++--- services/nats/pkg/command/server.go | 10 +++--- services/notifications/pkg/command/server.go | 10 +++--- services/ocdav/pkg/command/server.go | 10 +++--- services/ocm/pkg/command/server.go | 10 +++--- services/ocs/pkg/command/server.go | 10 +++--- services/policies/pkg/command/server.go | 10 +++--- services/postprocessing/pkg/command/server.go | 10 +++--- services/proxy/pkg/command/server.go | 36 ++++++++++--------- services/search/pkg/command/server.go | 10 +++--- services/settings/pkg/command/server.go | 10 +++--- services/sharing/pkg/command/server.go | 10 +++--- services/sse/pkg/command/server.go | 10 +++--- .../storage-publiclink/pkg/command/server.go | 10 +++--- services/storage-shares/pkg/command/server.go | 10 +++--- services/storage-system/pkg/command/server.go | 10 +++--- services/storage-users/pkg/command/server.go | 10 +++--- services/thumbnails/pkg/command/server.go | 10 +++--- services/userlog/pkg/command/server.go | 10 +++--- services/users/pkg/command/server.go | 10 +++--- services/web/pkg/command/server.go | 10 +++--- services/webdav/pkg/command/server.go | 10 +++--- services/webfinger/pkg/command/server.go | 10 +++--- 43 files changed, 241 insertions(+), 217 deletions(-) diff --git a/ocis-pkg/runner/grouprunner.go b/ocis-pkg/runner/grouprunner.go index 4c4574b9315..6d6de9d16fb 100644 --- a/ocis-pkg/runner/grouprunner.go +++ b/ocis-pkg/runner/grouprunner.go @@ -2,6 +2,7 @@ package runner import ( "context" + "errors" "sync" "sync/atomic" "time" @@ -83,6 +84,17 @@ func (gr *GroupRunner) Add(r *Runner) { gr.runnersCount++ } +// ProcessResults will process the results of the group runners and return joined errors. +func ProcessResults(results []*Result) error { + err := make([]error, 0, len(results)) + for _, result := range results { + if result.RunnerError != nil { + err = append(err, result.FormatError()) + } + } + return errors.Join(err...) +} + // Run will execute all the tasks in the group at the same time. // // Similarly to the "regular" runner's `Run` method, the execution thread diff --git a/ocis-pkg/runner/types.go b/ocis-pkg/runner/types.go index 4f226c18c2d..f7a33bed652 100644 --- a/ocis-pkg/runner/types.go +++ b/ocis-pkg/runner/types.go @@ -1,6 +1,7 @@ package runner import ( + "fmt" "os" "strings" "syscall" @@ -45,6 +46,15 @@ type Result struct { RunnerError error } +// FormatError formats the error of the result. +// If the error is nil, it returns nil +func (r *Result) FormatError() error { + if r.RunnerError != nil { + return fmt.Errorf("runner %s failed: %w", r.RunnerID, r.RunnerError) + } + return nil +} + // TimeoutError is an error that should be used for timeouts. // It implements the `error` interface type TimeoutError struct { diff --git a/services/activitylog/pkg/command/server.go b/services/activitylog/pkg/command/server.go index 0b813658e86..28bdf997f24 100644 --- a/services/activitylog/pkg/command/server.go +++ b/services/activitylog/pkg/command/server.go @@ -155,14 +155,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/antivirus/pkg/command/server.go b/services/antivirus/pkg/command/server.go index 84d83c12bb5..bbef759d5eb 100644 --- a/services/antivirus/pkg/command/server.go +++ b/services/antivirus/pkg/command/server.go @@ -75,14 +75,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/app-provider/pkg/command/server.go b/services/app-provider/pkg/command/server.go index 56bfd37ba51..82d57001998 100644 --- a/services/app-provider/pkg/command/server.go +++ b/services/app-provider/pkg/command/server.go @@ -83,14 +83,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/app-registry/pkg/command/server.go b/services/app-registry/pkg/command/server.go index f50567f5780..a12f211006c 100644 --- a/services/app-registry/pkg/command/server.go +++ b/services/app-registry/pkg/command/server.go @@ -82,14 +82,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/audit/pkg/command/server.go b/services/audit/pkg/command/server.go index 1694d23cc62..c8e29c94a49 100644 --- a/services/audit/pkg/command/server.go +++ b/services/audit/pkg/command/server.go @@ -76,14 +76,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/auth-app/pkg/command/server.go b/services/auth-app/pkg/command/server.go index 5c6bd72b800..84d56c6325d 100644 --- a/services/auth-app/pkg/command/server.go +++ b/services/auth-app/pkg/command/server.go @@ -130,14 +130,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGoMicroHttpServerRunner("auth-app_http", server)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/auth-basic/pkg/command/server.go b/services/auth-basic/pkg/command/server.go index 16c2a075a28..3fa525cb1f2 100644 --- a/services/auth-basic/pkg/command/server.go +++ b/services/auth-basic/pkg/command/server.go @@ -95,14 +95,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/auth-bearer/pkg/command/server.go b/services/auth-bearer/pkg/command/server.go index d7952744766..0f657af061a 100644 --- a/services/auth-bearer/pkg/command/server.go +++ b/services/auth-bearer/pkg/command/server.go @@ -82,14 +82,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/auth-machine/pkg/command/server.go b/services/auth-machine/pkg/command/server.go index 85566507ea1..1a98dd29919 100644 --- a/services/auth-machine/pkg/command/server.go +++ b/services/auth-machine/pkg/command/server.go @@ -82,14 +82,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/auth-service/pkg/command/server.go b/services/auth-service/pkg/command/server.go index a98875dd69e..2c6470f1c34 100644 --- a/services/auth-service/pkg/command/server.go +++ b/services/auth-service/pkg/command/server.go @@ -82,14 +82,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/clientlog/pkg/command/server.go b/services/clientlog/pkg/command/server.go index e99f670dfed..53023ecc98f 100644 --- a/services/clientlog/pkg/command/server.go +++ b/services/clientlog/pkg/command/server.go @@ -130,14 +130,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/collaboration/pkg/command/server.go b/services/collaboration/pkg/command/server.go index 9fad2e19319..d27e46cd586 100644 --- a/services/collaboration/pkg/command/server.go +++ b/services/collaboration/pkg/command/server.go @@ -134,14 +134,14 @@ func Server(cfg *config.Config) *cli.Command { } gr.Add(runner.NewGoMicroHttpServerRunner("collaboration_http", httpServer)) + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/eventhistory/pkg/command/server.go b/services/eventhistory/pkg/command/server.go index 9ee0c172f04..06df1fd00bb 100644 --- a/services/eventhistory/pkg/command/server.go +++ b/services/eventhistory/pkg/command/server.go @@ -103,14 +103,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/frontend/pkg/command/server.go b/services/frontend/pkg/command/server.go index fca2db4934a..61ee877fae8 100644 --- a/services/frontend/pkg/command/server.go +++ b/services/frontend/pkg/command/server.go @@ -96,14 +96,14 @@ func Server(cfg *config.Config) *cli.Command { }, )) + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/gateway/pkg/command/server.go b/services/gateway/pkg/command/server.go index 8fcca646aa5..ff37244c8eb 100644 --- a/services/gateway/pkg/command/server.go +++ b/services/gateway/pkg/command/server.go @@ -82,14 +82,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/graph/pkg/command/server.go b/services/graph/pkg/command/server.go index 25c19888c67..d96cd8496f0 100644 --- a/services/graph/pkg/command/server.go +++ b/services/graph/pkg/command/server.go @@ -75,14 +75,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", server)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/groups/pkg/command/server.go b/services/groups/pkg/command/server.go index ffc3950758b..2235741d365 100644 --- a/services/groups/pkg/command/server.go +++ b/services/groups/pkg/command/server.go @@ -95,14 +95,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/idm/pkg/command/server.go b/services/idm/pkg/command/server.go index 8909f08e91f..5c5494a0688 100644 --- a/services/idm/pkg/command/server.go +++ b/services/idm/pkg/command/server.go @@ -104,14 +104,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/invitations/pkg/command/server.go b/services/invitations/pkg/command/server.go index 45d2207d9fd..20705dfc924 100644 --- a/services/invitations/pkg/command/server.go +++ b/services/invitations/pkg/command/server.go @@ -93,14 +93,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/nats/pkg/command/server.go b/services/nats/pkg/command/server.go index 5d24f5c15bf..b7445f35d78 100644 --- a/services/nats/pkg/command/server.go +++ b/services/nats/pkg/command/server.go @@ -94,14 +94,14 @@ func Server(cfg *config.Config) *cli.Command { natsServer.Shutdown() })) + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/notifications/pkg/command/server.go b/services/notifications/pkg/command/server.go index a681ffbf0cf..4afe1fc7a11 100644 --- a/services/notifications/pkg/command/server.go +++ b/services/notifications/pkg/command/server.go @@ -147,14 +147,14 @@ func Server(cfg *config.Config) *cli.Command { svc.Close() })) + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/ocdav/pkg/command/server.go b/services/ocdav/pkg/command/server.go index 3004f10f6ac..1eb60b56ef0 100644 --- a/services/ocdav/pkg/command/server.go +++ b/services/ocdav/pkg/command/server.go @@ -120,14 +120,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/ocm/pkg/command/server.go b/services/ocm/pkg/command/server.go index 0bf069efb61..aa109c22a3b 100644 --- a/services/ocm/pkg/command/server.go +++ b/services/ocm/pkg/command/server.go @@ -87,14 +87,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the http service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/ocs/pkg/command/server.go b/services/ocs/pkg/command/server.go index 88641c2d059..c4b60943eae 100644 --- a/services/ocs/pkg/command/server.go +++ b/services/ocs/pkg/command/server.go @@ -87,14 +87,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/policies/pkg/command/server.go b/services/policies/pkg/command/server.go index 7fbe09463ca..c2a8076d1b5 100644 --- a/services/policies/pkg/command/server.go +++ b/services/policies/pkg/command/server.go @@ -139,14 +139,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/postprocessing/pkg/command/server.go b/services/postprocessing/pkg/command/server.go index 66226c95f45..eeb99c73f12 100644 --- a/services/postprocessing/pkg/command/server.go +++ b/services/postprocessing/pkg/command/server.go @@ -93,14 +93,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner("postprocessing_debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/proxy/pkg/command/server.go b/services/proxy/pkg/command/server.go index f25be442bf1..a64ed94784b 100644 --- a/services/proxy/pkg/command/server.go +++ b/services/proxy/pkg/command/server.go @@ -57,6 +57,19 @@ func Server(cfg *config.Config) *cli.Command { return configlog.ReturnFatal(parser.ParseConfig(cfg)) }, Action: func(c *cli.Context) error { + logger := logging.Configure(cfg.Service.Name, cfg.Log) + traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) + if err != nil { + return err + } + + var cancel context.CancelFunc + if cfg.Context == nil { + cfg.Context, cancel = signal.NotifyContext(context.Background(), runner.StopSignals...) + defer cancel() + } + ctx := cfg.Context + userInfoCache := store.Create( store.Store(cfg.OIDC.UserinfoCache.Store), store.TTL(cfg.OIDC.UserinfoCache.TTL), @@ -76,11 +89,6 @@ func Server(cfg *config.Config) *cli.Command { store.Authentication(cfg.PreSignedURL.SigningKeys.AuthUsername, cfg.PreSignedURL.SigningKeys.AuthPassword), ) - logger := logging.Configure(cfg.Service.Name, cfg.Log) - traceProvider, err := tracing.GetServiceTraceProvider(cfg.Tracing, cfg.Service.Name) - if err != nil { - return err - } cfg.GrpcClient, err = grpc.NewClient( append( grpc.GetClientOptions(cfg.GRPCClientTLS), @@ -108,12 +116,6 @@ func Server(cfg *config.Config) *cli.Command { oidc.WithJWKSOptions(cfg.OIDC.JWKS), ) - var cancel context.CancelFunc - if cfg.Context == nil { - cfg.Context, cancel = signal.NotifyContext(context.Background(), runner.StopSignals...) - defer cancel() - } - m := metrics.New() m.BuildInfo.WithLabelValues(version.GetString()).Set(1) @@ -222,14 +224,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } - grResults := gr.Run(cfg.Context) + logger.Warn().Msgf("starting service %s", cfg.Service.Name) + grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/search/pkg/command/server.go b/services/search/pkg/command/server.go index 047c0640691..a2cc6a78b13 100644 --- a/services/search/pkg/command/server.go +++ b/services/search/pkg/command/server.go @@ -83,14 +83,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/settings/pkg/command/server.go b/services/settings/pkg/command/server.go index 87f45a7c3d2..b606a93eb06 100644 --- a/services/settings/pkg/command/server.go +++ b/services/settings/pkg/command/server.go @@ -100,14 +100,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/sharing/pkg/command/server.go b/services/sharing/pkg/command/server.go index d8826d9f5ec..5358dc4154c 100644 --- a/services/sharing/pkg/command/server.go +++ b/services/sharing/pkg/command/server.go @@ -100,14 +100,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/sse/pkg/command/server.go b/services/sse/pkg/command/server.go index 13818d1c284..562726b9bf2 100644 --- a/services/sse/pkg/command/server.go +++ b/services/sse/pkg/command/server.go @@ -92,14 +92,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/storage-publiclink/pkg/command/server.go b/services/storage-publiclink/pkg/command/server.go index 3a03e55d822..d5ea232c670 100644 --- a/services/storage-publiclink/pkg/command/server.go +++ b/services/storage-publiclink/pkg/command/server.go @@ -82,14 +82,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/storage-shares/pkg/command/server.go b/services/storage-shares/pkg/command/server.go index bd30cced027..8b353299be7 100644 --- a/services/storage-shares/pkg/command/server.go +++ b/services/storage-shares/pkg/command/server.go @@ -82,14 +82,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/storage-system/pkg/command/server.go b/services/storage-system/pkg/command/server.go index 718ee7fdfdc..d7d170e7c23 100644 --- a/services/storage-system/pkg/command/server.go +++ b/services/storage-system/pkg/command/server.go @@ -88,14 +88,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the http service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/storage-users/pkg/command/server.go b/services/storage-users/pkg/command/server.go index dd4d992eb2a..7c1c62045f3 100644 --- a/services/storage-users/pkg/command/server.go +++ b/services/storage-users/pkg/command/server.go @@ -108,14 +108,14 @@ func Server(cfg *config.Config) *cli.Command { }() } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/thumbnails/pkg/command/server.go b/services/thumbnails/pkg/command/server.go index 501344b716a..054e4512c00 100644 --- a/services/thumbnails/pkg/command/server.go +++ b/services/thumbnails/pkg/command/server.go @@ -95,14 +95,14 @@ func Server(cfg *config.Config) *cli.Command { } gr.Add(runner.NewGoMicroHttpServerRunner(cfg.Service.Name+".http", httpServer)) + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/userlog/pkg/command/server.go b/services/userlog/pkg/command/server.go index beb6f69a1aa..615ae1e2ecc 100644 --- a/services/userlog/pkg/command/server.go +++ b/services/userlog/pkg/command/server.go @@ -155,14 +155,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/users/pkg/command/server.go b/services/users/pkg/command/server.go index 4b32e94eb62..58bc5292bb3 100644 --- a/services/users/pkg/command/server.go +++ b/services/users/pkg/command/server.go @@ -96,14 +96,14 @@ func Server(cfg *config.Config) *cli.Command { logger.Fatal().Err(err).Msg("failed to register the grpc service") } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/web/pkg/command/server.go b/services/web/pkg/command/server.go index e594c19481f..9380b4ada30 100644 --- a/services/web/pkg/command/server.go +++ b/services/web/pkg/command/server.go @@ -93,14 +93,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/webdav/pkg/command/server.go b/services/webdav/pkg/command/server.go index 3647e679038..3c977531eb6 100644 --- a/services/webdav/pkg/command/server.go +++ b/services/webdav/pkg/command/server.go @@ -89,14 +89,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, } diff --git a/services/webfinger/pkg/command/server.go b/services/webfinger/pkg/command/server.go index 4eb820cab4f..4c44b8ffb81 100644 --- a/services/webfinger/pkg/command/server.go +++ b/services/webfinger/pkg/command/server.go @@ -102,14 +102,14 @@ func Server(cfg *config.Config) *cli.Command { gr.Add(runner.NewGolangHttpServerRunner(cfg.Service.Name+".debug", debugServer)) } + logger.Warn().Msgf("starting service %s", cfg.Service.Name) grResults := gr.Run(ctx) - // return the first non-nil error found in the results - for _, grResult := range grResults { - if grResult.RunnerError != nil { - return grResult.RunnerError - } + if err := runner.ProcessResults(grResults); err != nil { + logger.Error().Err(err).Msgf("service %s stopped with error", cfg.Service.Name) + return err } + logger.Warn().Msgf("service %s stopped without error", cfg.Service.Name) return nil }, }