From 200857159766d3c6c5831450048348444c5666f4 Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Thu, 23 Jan 2025 14:54:12 +0100 Subject: perf: pass context to importer for better tracing --- cmd/searchix-web/main.go | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) (limited to 'cmd') diff --git a/cmd/searchix-web/main.go b/cmd/searchix-web/main.go index 63b1ec5..2cffb6b 100644 --- a/cmd/searchix-web/main.go +++ b/cmd/searchix-web/main.go @@ -53,12 +53,15 @@ func main() { log.SetLevel(cfg.LogLevel) + ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) + defer cancel() + s, err := searchix.New(cfg, logger) if err != nil { logger.Fatal("Failed to initialise searchix", "error", err) } - err = s.SetupIndex(&searchix.IndexOptions{ + err = s.SetupIndex(ctx, &searchix.IndexOptions{ Update: *update, Replace: *replace, LowMemory: cfg.Importer.LowMemory, @@ -69,12 +72,9 @@ func main() { } if *replace || *update { - os.Exit(0) + return } - ctx, cancel := signal.NotifyContext(context.Background(), os.Interrupt) - defer cancel() - go func() { err = s.Start(ctx, *dev) if err != nil { -- cgit 1.4.1