all repos — searchix @ 832214d72d377f7c02146a77528b6e9c6bb393c8

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

feat: re- ingest/index on SIGUSR1/2

Alan Pearce
commit

832214d72d377f7c02146a77528b6e9c6bb393c8

parent

12a29a55fe895a964d8d317857ee7fb87d4071f1

1 file changed, 22 insertions(+), 0 deletions(-)

changed files
M cmd/searchix-web/serve.gocmd/searchix-web/serve.go
@@ -119,6 +119,28 @@ logger.Fatal("error", "error", err)
} }() + reimport := make(chan os.Signal, 1) + go func() { + for sig := range reimport { + if sig == syscall.SIGUSR1 { + logger.Info("manual fetch on SIGUSR1") + err := imp.Fetch(ctx, false, false, nil) + if err != nil { + logger.Warn("manual fetch error", "error", err) + } + logger.Info("manual fetch succeeded") + } + + logger.Info("manual re-index", "signal", sig.String()) + err := imp.Index(ctx) + if err != nil { + logger.Error("manual index error", "error", err) + } + logger.Info("manual re-index completed") + } + }() + signal.Notify(reimport, syscall.SIGUSR1, syscall.SIGUSR2) + wg.Add(1) go func() { defer wg.Done()