about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2025-01-18 14:50:19 +0100
committerAlan Pearce2025-01-18 14:50:19 +0100
commitb706b5a3d09983637ea6d5af515733d77b674bdb (patch)
treec8c670dcd21d496de47b84cbc729217c147e19fa
parente7e7d135733e31a6f3d241befd6dcc8e8badf5bf (diff)
downloadsearchix-b706b5a3d09983637ea6d5af515733d77b674bdb.tar.lz
searchix-b706b5a3d09983637ea6d5af515733d77b674bdb.tar.zst
searchix-b706b5a3d09983637ea6d5af515733d77b674bdb.zip
fix: use importer configured timeout for sentry check-ins
-rw-r--r--searchix.go9
1 files changed, 5 insertions, 4 deletions
diff --git a/searchix.go b/searchix.go
index 534624e..6cbb4e7 100644
--- a/searchix.go
+++ b/searchix.go
@@ -2,6 +2,7 @@ package searchix
 
 import (
 	"context"
+	"math"
 	"slices"
 	"sync"
 	"time"
@@ -154,6 +155,7 @@ func New(cfg *config.Config, log *log.Logger) (*Server, error) {
 
 func (s *Server) startUpdateTimer(
 	ctx context.Context,
+	cfg *config.Config,
 	localHub *sentry.Hub,
 ) {
 	const monitorSlug = "import"
@@ -161,9 +163,8 @@ func (s *Server) startUpdateTimer(
 		var err error
 		scope.SetContext("monitor", sentry.Context{"slug": monitorSlug})
 		monitorConfig := &sentry.MonitorConfig{
-			Schedule: sentry.IntervalSchedule(1, sentry.MonitorScheduleUnitDay),
-			// minutes
-			MaxRuntime:    10,
+			Schedule:      sentry.IntervalSchedule(1, sentry.MonitorScheduleUnitDay),
+			MaxRuntime:    int64(math.Ceil(cfg.Importer.Timeout.Minutes())),
 			CheckInMargin: 5,
 			Timezone:      time.Local.String(),
 		}
@@ -221,7 +222,7 @@ func (s *Server) Start(ctx context.Context, liveReload bool) error {
 	}
 
 	s.wg = &sync.WaitGroup{}
-	go s.startUpdateTimer(ctx, sentry.CurrentHub().Clone())
+	go s.startUpdateTimer(ctx, s.cfg, sentry.CurrentHub().Clone())
 
 	s.wg.Add(1)
 	err = s.sv.Start()