collect the errors from group runner

This commit is contained in:
Roman Perekhod
2025-06-10 18:21:49 +02:00
parent a5c524423d
commit 4fc4822696
43 changed files with 241 additions and 217 deletions

View File

@@ -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

View File

@@ -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 {

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}

View File

@@ -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
},
}