main.go raw
1 package main
2
3 import (
4 "context"
5 "flag"
6 "os"
7 "os/signal"
8 "syscall"
9
10 "git.smesh.lol/orly/pkg/database"
11 "git.smesh.lol/orly/pkg/lol/log"
12 )
13
14 func main() {
15 dbPath := flag.String("db", "", "Path to badger database directory")
16 flag.Parse()
17
18 if *dbPath == "" {
19 log.E.F("Usage: reindex-ppg -db /path/to/database")
20 os.Exit(1)
21 }
22
23 ctx, cancel := context.WithCancel(context.Background())
24 defer cancel()
25
26 // Handle shutdown signals
27 sigChan := make(chan os.Signal, 1)
28 signal.Notify(sigChan, os.Interrupt, syscall.SIGTERM)
29 go func() {
30 <-sigChan
31 log.I.F("Received shutdown signal, canceling...")
32 cancel()
33 }()
34
35 log.I.F("Opening database at %s", *dbPath)
36 db, err := database.New(ctx, cancel, *dbPath, "info")
37 if err != nil {
38 log.E.F("Failed to open database: %v", err)
39 os.Exit(1)
40 }
41 defer db.Close()
42
43 log.I.F("Starting PPG/GPP index rebuild...")
44 db.BackfillPubkeyPubkeyGraph()
45 log.I.F("PPG/GPP index rebuild complete!")
46 }
47