2 Commits

Author SHA1 Message Date
xuu
114c7101d6 fix: add debug levels
All checks were successful
Go Bump / bump (push) Successful in 43s
Go Test / test (push) Successful in 49s
Deploy / deploy (push) Successful in 1m42s
2023-10-07 17:57:09 -06:00
xuu
41476d04a2 fix: null pointer when unable to startu peerfinder
All checks were successful
Go Bump / bump (push) Successful in 30s
Go Test / test (push) Successful in 43s
Deploy / deploy (push) Successful in 1m25s
2023-10-02 11:26:14 -06:00
2 changed files with 15 additions and 5 deletions

View File

@@ -91,17 +91,17 @@ func (s *service) Run(ctx context.Context) (err error) {
subRes, e := s.es.EventStream().Subscribe(ctx, queueResults, 0)
errs = multierr.Append(errs, e)
if errs != nil {
return errs
}
defer func() {
ctx, cancel := context.WithTimeout(context.Background(), 1*time.Second)
defer cancel()
err = multierr.Combine(errs, subReq.Close(ctx), subRes.Close(ctx))
err = multierr.Combine(err, subReq.Close(ctx), subRes.Close(ctx))
}()
if errs != nil {
return errs
}
for {
var events event.Events
select {

View File

@@ -4,10 +4,13 @@ import (
"context"
"errors"
"log"
"log/slog"
"net/http"
"os"
"os/signal"
"strconv"
"go.sour.is/pkg/env"
"go.sour.is/pkg/lg"
"go.sour.is/pkg/service"
)
@@ -27,6 +30,13 @@ func main() {
}
}
func run(ctx context.Context) error {
// TODO: make this configurable.
level := slog.LevelError
if ok, _ := strconv.ParseBool(env.Default("LOG_DEBUG", "FALSE")); ok {
level = slog.LevelDebug
}
slog.SetDefault(slog.New(slog.NewTextHandler(os.Stdout, &slog.HandlerOptions{Level: level})))
svc := &service.Harness{}
ctx, stop := lg.Init(ctx, appName)
svc.OnStop(stop)