about summary refs log tree commit diff stats
diff options
context:
space:
mode:
authorAlan Pearce2024-12-04 17:28:48 +0100
committerAlan Pearce2024-12-04 17:28:48 +0100
commitc92530b7940bfd9e0940dd07e4a33b8dc4b575ea (patch)
tree465c3d05b2034e1a0c1daefcad2c645c79bfd90a
parentec4946ee959b2d7d28287e9cd4643a0698833f6b (diff)
downloadsearchix-c92530b7940bfd9e0940dd07e4a33b8dc4b575ea.tar.lz
searchix-c92530b7940bfd9e0940dd07e4a33b8dc4b575ea.tar.zst
searchix-c92530b7940bfd9e0940dd07e4a33b8dc4b575ea.zip
fix: use UTC time for fetch/import timer
-rw-r--r--defaults.toml4
-rw-r--r--internal/config/default.go2
-rw-r--r--internal/config/structs.go2
-rw-r--r--justfile3
-rw-r--r--searchix.go7
5 files changed, 10 insertions, 8 deletions
diff --git a/defaults.toml b/defaults.toml
index 66f0d07..4f95929 100644
--- a/defaults.toml
+++ b/defaults.toml
@@ -64,8 +64,8 @@ x-frame-options = 'DENY'
 LowMemory = false
 # Abort fetch and import process for all jobs if it takes longer than this value.
 Timeout = '30m0s'
-# Local time of day to run fetch/import process
-UpdateAt = '04:00:00'
+# Time of day (UTC) to run fetch/import process
+UpdateAt = '03:00:00'
 
 [Importer.Sources]
 [Importer.Sources.darwin]
diff --git a/internal/config/default.go b/internal/config/default.go
index d6ad6f7..a857799 100644
--- a/internal/config/default.go
+++ b/internal/config/default.go
@@ -49,7 +49,7 @@ var DefaultConfig = Config{
 	Importer: &Importer{
 		LowMemory: false,
 		Timeout:   Duration{30 * time.Minute},
-		UpdateAt:  mustLocalTime("04:00:00"),
+		UpdateAt:  mustLocalTime("03:00:00"),
 		Sources: map[string]*Source{
 			"nixos": {
 				Name:       "NixOS",
diff --git a/internal/config/structs.go b/internal/config/structs.go
index dd79303..b31e0cd 100644
--- a/internal/config/structs.go
+++ b/internal/config/structs.go
@@ -31,7 +31,7 @@ type Importer struct {
 	Sources   map[string]*Source
 	LowMemory bool      `comment:"Use less memory at the expense of import performance"`
 	Timeout   Duration  `comment:"Abort fetch and import process for all jobs if it takes longer than this value."`
-	UpdateAt  LocalTime `comment:"Local time of day to run fetch/import process"`
+	UpdateAt  LocalTime `comment:"Time of day (UTC) to run fetch/import process"`
 }
 
 type Source struct {
diff --git a/justfile b/justfile
index 46c927a..dfa7bec 100644
--- a/justfile
+++ b/justfile
@@ -27,6 +27,9 @@ format:
 fix:
 	go fix .
 
+generate-defaults:
+	wgo run --exit ./cmd/searchix-web --print-default-config > defaults.toml
+
 precommit:
 	nix-build -A pre-commit-check
 
diff --git a/searchix.go b/searchix.go
index 558847f..534624e 100644
--- a/searchix.go
+++ b/searchix.go
@@ -13,11 +13,10 @@ import (
 	"go.alanpearce.eu/x/log"
 
 	"github.com/getsentry/sentry-go"
-	"github.com/pelletier/go-toml/v2"
 	"github.com/pkg/errors"
 )
 
-func nextOccurrenceOfLocalTime(t toml.LocalTime) time.Time {
+func nextUTCOccurrenceOfTime(t config.LocalTime) time.Time {
 	now := time.Now()
 	dayTime := t
 	nextRun := time.Date(
@@ -28,7 +27,7 @@ func nextOccurrenceOfLocalTime(t toml.LocalTime) time.Time {
 		dayTime.Minute,
 		dayTime.Second,
 		0,
-		time.Local,
+		time.UTC,
 	)
 	if nextRun.Before(now) {
 		return nextRun.AddDate(0, 0, 1)
@@ -170,7 +169,7 @@ func (s *Server) startUpdateTimer(
 		}
 
 		s.wg.Add(1)
-		nextRun := nextOccurrenceOfLocalTime(s.cfg.Importer.UpdateAt.LocalTime)
+		nextRun := nextUTCOccurrenceOfTime(s.cfg.Importer.UpdateAt)
 		for {
 			s.log.Debug("scheduling next run", "next-run", nextRun)
 			select {