Skip to content

Commit

Permalink
Clearly log when runners terminate
Browse files Browse the repository at this point in the history
  • Loading branch information
boreq committed Dec 14, 2023
1 parent 6105ef9 commit bd78082
Show file tree
Hide file tree
Showing 2 changed files with 10 additions and 5 deletions.
13 changes: 9 additions & 4 deletions cmd/event-service/di/service.go
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ import (

"github.com/boreq/errors"
"github.com/hashicorp/go-multierror"
"github.com/planetary-social/nos-event-service/internal/logging"
"github.com/planetary-social/nos-event-service/internal/migrations"
"github.com/planetary-social/nos-event-service/service/adapters/sqlite"
"github.com/planetary-social/nos-event-service/service/app"
Expand All @@ -27,6 +28,7 @@ type Service struct {
migrationsRunner *migrations.Runner
migrations migrations.Migrations
migrationsProgressCallback migrations.ProgressCallback
logger logging.Logger
}

func NewService(
Expand All @@ -41,6 +43,7 @@ func NewService(
migrationsRunner *migrations.Runner,
migrations migrations.Migrations,
migrationsProgressCallback migrations.ProgressCallback,
logger logging.Logger,
) Service {
return Service{
app: app,
Expand All @@ -54,6 +57,7 @@ func NewService(
taskScheduler: taskScheduler,
migrations: migrations,
migrationsProgressCallback: migrationsProgressCallback,
logger: logger.New("service"),
}
}

Expand Down Expand Up @@ -107,11 +111,12 @@ func (s Service) Run(ctx context.Context) error {
errCh <- errors.Wrap(s.taskScheduler.Run(ctx), "task scheduler error")
}()

var err error
var compoundErr error
for i := 0; i < runners; i++ {
err = multierror.Append(err, errors.Wrap(<-errCh, "error returned by runner"))
err := errors.Wrap(<-errCh, "error returned by runner")
s.logger.Error().WithError(err).Message("runner terminated")
compoundErr = multierror.Append(compoundErr, err)
cancel()
}

return err
return compoundErr
}
2 changes: 1 addition & 1 deletion cmd/event-service/di/wire_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

0 comments on commit bd78082

Please sign in to comment.