mirror of
https://github.com/owncloud/ocis
synced 2026-04-25 17:25:21 +02:00
collect the errors from group runner
This commit is contained in:
@@ -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
|
||||
|
||||
@@ -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 {
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
@@ -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
|
||||
},
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user