-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathblobstash.go
61 lines (53 loc) · 1.63 KB
/
blobstash.go
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
//go:generate go run tools/genluaindex/genluaindex.go
//go:generate go run tools/genjs/genjs.go
package main
import (
"flag"
"log"
"a4.io/blobstash/pkg/config"
"a4.io/blobstash/pkg/server"
)
var (
scan bool
s3scan bool
s3restore bool
docstoreIndexesReindex bool
check bool
loglevel string
err error
)
func main() {
flag.BoolVar(&check, "check", false, "Check the blobstore consistency.")
flag.BoolVar(&scan, "scan", false, "Trigger a BlobStore rescan.")
flag.BoolVar(&s3scan, "s3-scan", false, "Trigger a BlobStore rescan of the S3 backend.")
flag.BoolVar(&s3restore, "s3-restore", false, "Trigger a BlobStore restore of the S3 backend.")
flag.BoolVar(&docstoreIndexesReindex, "docstore-indexes-reindex", false, "Trigger a re-indexing of all document store sort indexes.")
flag.StringVar(&loglevel, "loglevel", "", "logging level (debug|info|warn|crit)")
flag.Parse()
conf := &config.Config{}
if flag.NArg() == 1 {
conf, err = config.New(flag.Arg(0))
if err != nil {
log.Fatalf("failed to load config at \"%v\": %v", flag.Arg(0), err)
}
}
// Set the ScanMode in the config
conf.CheckMode = check
conf.ScanMode = scan
conf.S3ScanMode = s3scan
conf.S3RestoreMode = s3restore
conf.DocstoreIndexesReindexMode = docstoreIndexesReindex
if loglevel != "" {
conf.LogLevel = loglevel
}
s, err := server.New(conf)
if err != nil {
log.Fatalf("failed to initialize server: %v", err)
}
if err := s.Bootstrap(); err != nil {
log.Fatalf("failed: %v", err)
}
if err := s.Serve(); err != nil {
log.Fatalf("failed: %v", err)
}
}