all repos — searchix @ c92530b7940bfd9e0940dd07e4a33b8dc4b575ea

Search engine for NixOS, nix-darwin, home-manager and NUR users

fix: use UTC time for fetch/import timer

Alan Pearce
commit

c92530b7940bfd9e0940dd07e4a33b8dc4b575ea

parent

ec4946ee959b2d7d28287e9cd4643a0698833f6b

5 files changed, 10 insertions(+), 8 deletions(-)

jump to
M defaults.tomldefaults.toml
@@ -64,8 +64,8 @@ # Use less memory at the expense of import performance
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]
M internal/config/default.gointernal/config/default.go
@@ -49,7 +49,7 @@ },
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",
M internal/config/structs.gointernal/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 {
M justfilejustfile
@@ -27,6 +27,9 @@
fix: go fix . +generate-defaults: + wgo run --exit ./cmd/searchix-web --print-default-config > defaults.toml + precommit: nix-build -A pre-commit-check
M searchix.gosearchix.go
@@ -13,11 +13,10 @@ "go.alanpearce.eu/searchix/internal/server"
"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 @@ dayTime.Hour,
dayTime.Minute, dayTime.Second, 0, - time.Local, + time.UTC, ) if nextRun.Before(now) { return nextRun.AddDate(0, 0, 1)
@@ -170,7 +169,7 @@ Timezone: time.Local.String(),
} 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 {