fix: shutdown on error
All checks were successful
Go Bump / bump (push) Successful in 35s
Go Test / build (push) Successful in 40s

This commit is contained in:
xuu 2023-10-19 16:52:55 -06:00
parent 7725019ed7
commit b1cc2af8d8
Signed by: xuu
GPG Key ID: 8B3B0604F164E04F
3 changed files with 7 additions and 4 deletions

2
go.mod
View File

@ -1,6 +1,6 @@
module go.sour.is/pkg module go.sour.is/pkg
go 1.20 go 1.21
require ( require (
github.com/99designs/gqlgen v0.17.34 github.com/99designs/gqlgen v0.17.34

View File

@ -71,7 +71,7 @@ func (w wrapSpan) AddEvent(name string, options ...trace.EventOption) {
args[2*i+1] = a.Value args[2*i+1] = a.Value
} }
slog.Info(name, args...) slog.Debug(name, args...)
} }
func (w wrapSpan) RecordError(err error, options ...trace.EventOption) { func (w wrapSpan) RecordError(err error, options ...trace.EventOption) {
@ -142,7 +142,7 @@ func initTracing(ctx context.Context, name string) (context.Context, func() erro
return ctx, nil return ctx, nil
} }
exporterAddr := env.Default("EV_TRACE_ENDPOINT", "") exporterAddr := env.Default("TRACE_ENDPOINT", "")
if exporterAddr == "" { if exporterAddr == "" {
return ctx, nil return ctx, nil
} }

View File

@ -93,7 +93,7 @@ func (s *Harness) Run(ctx context.Context, appName, version string) error {
span.End() span.End()
} }
g, _ := errgroup.WithContext(ctx) g, ctx := errgroup.WithContext(ctx)
g.Go(func() error { g.Go(func() error {
<-ctx.Done() <-ctx.Done()
// shutdown jobs // shutdown jobs
@ -111,7 +111,10 @@ func (s *Harness) Run(ctx context.Context, appName, version string) error {
close(s.onRunning) close(s.onRunning)
err := g.Wait() err := g.Wait()
if err != nil {
log.Printf("Shutdown due to error: %s", err)
}
return err return err
} }