From 6b40e0c0fa90f11be14a93f1d6275779fd645cac Mon Sep 17 00:00:00 2001 From: Alan Pearce Date: Mon, 13 May 2024 21:50:14 +0200 Subject: refactor: combine import and web server into one binary --- internal/server/mux.go | 17 +++++++---------- 1 file changed, 7 insertions(+), 10 deletions(-) (limited to 'internal/server/mux.go') diff --git a/internal/server/mux.go b/internal/server/mux.go index 9d3b29a..582d154 100644 --- a/internal/server/mux.go +++ b/internal/server/mux.go @@ -16,8 +16,8 @@ import ( "searchix/frontend" "searchix/internal/config" + search "searchix/internal/index" "searchix/internal/options" - "searchix/internal/search" "github.com/blevesearch/bleve/v2" "github.com/getsentry/sentry-go" @@ -63,15 +63,12 @@ func applyDevModeOverrides(config *config.Config) { ) } -func NewMux(config *config.Config, liveReload bool) (*http.ServeMux, error) { - slog.Debug("loading index") - index, err := search.Open(config.DataPath) - slog.Debug("loaded index") - if err != nil { - log.Fatalf("could not open search index, error: %#v", err) - } - - err = sentry.Init(sentry.ClientOptions{ +func NewMux( + config *config.Config, + index *search.ReadIndex, + liveReload bool, +) (*http.ServeMux, error) { + err := sentry.Init(sentry.ClientOptions{ EnableTracing: true, TracesSampleRate: 1.0, Dsn: config.Web.SentryDSN, -- cgit 1.4.1