about summary refs log tree commit diff stats
path: root/serve/main.go
diff options
context:
space:
mode:
authorAlan Pearce2024-05-13 21:50:14 +0200
committerAlan Pearce2024-05-13 22:25:46 +0200
commit6b40e0c0fa90f11be14a93f1d6275779fd645cac (patch)
tree0df5bea87242450829ca441d235c077a0e09a149 /serve/main.go
parent2722f24af87f437ed9fcb8cc743ad1784141fd3a (diff)
downloadsearchix-6b40e0c0fa90f11be14a93f1d6275779fd645cac.tar.lz
searchix-6b40e0c0fa90f11be14a93f1d6275779fd645cac.tar.zst
searchix-6b40e0c0fa90f11be14a93f1d6275779fd645cac.zip
refactor: combine import and web server into one binary
Diffstat (limited to 'serve/main.go')
-rw-r--r--serve/main.go60
1 files changed, 0 insertions, 60 deletions
diff --git a/serve/main.go b/serve/main.go
deleted file mode 100644
index 709d340..0000000
--- a/serve/main.go
+++ /dev/null
@@ -1,60 +0,0 @@
-package main
-
-import (
-	"flag"
-	"log"
-	"log/slog"
-	"os"
-	"os/signal"
-	"sync"
-
-	"searchix/internal/config"
-	"searchix/internal/server"
-)
-
-var (
-	liveReload = flag.Bool("live", false, "whether to enable live reloading (development)")
-	configFile = flag.String("config", "config.toml", "config file to use")
-)
-
-func main() {
-	flag.Parse()
-
-	conf, err := config.GetConfig(*configFile)
-	if err != nil {
-		log.Panicf("error parsing configuration file: %v", err)
-	}
-	slog.SetLogLoggerLevel(conf.LogLevel)
-	log.SetFlags(log.LstdFlags | log.Lmsgprefix)
-	log.SetPrefix("searchix: ")
-
-	c := make(chan os.Signal, 2)
-	signal.Notify(c, os.Interrupt)
-	sv, err := server.New(conf, *liveReload)
-	if err != nil {
-		log.Fatalf("error setting up server: %v", err)
-	}
-	wg := &sync.WaitGroup{}
-	wg.Add(1)
-	go func() {
-		defer wg.Done()
-		sig := <-c
-		log.Printf("signal captured: %v", sig)
-		<-sv.Stop()
-		slog.Debug("server stopped")
-	}()
-
-	sErr := make(chan error)
-	wg.Add(1)
-	go func() {
-		defer wg.Done()
-		sErr <- sv.Start()
-	}()
-
-	err = <-sErr
-	if err != nil {
-		// Error starting or closing listener:
-		log.Fatalf("error: %v", err)
-	}
-	wg.Wait()
-}