-
Notifications
You must be signed in to change notification settings - Fork 7
/
main.go
58 lines (47 loc) · 1.2 KB
/
main.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
package main
import (
"flag"
"os"
"path/filepath"
"github.com/HolmesProcessing/Holmes-Storage/amqp"
"github.com/HolmesProcessing/Holmes-Storage/context"
"github.com/HolmesProcessing/Holmes-Storage/http"
)
func main() {
var (
setup bool
objSetup bool
confPath string
)
flag.BoolVar(&setup, "setup", false, "Setup the Database")
flag.BoolVar(&objSetup, "objSetup", false, "Setup the object storage")
flag.StringVar(&confPath, "config", "", "Path to the config file")
flag.Parse()
// load config
if confPath == "" {
confPath, _ = filepath.Abs(filepath.Dir(os.Args[0]))
confPath += "/config/storage.conf"
}
ctx := &context.Ctx{}
ctx.Initialize(confPath)
ctx.Debug.Println("Initialization finished")
if setup {
err := ctx.Data.Setup()
if err == nil {
ctx.Info.Println("Setup complete, no errors")
} else {
ctx.Info.Panic("Setup couldn't finish without errors: " + err.Error())
}
}
if objSetup {
err := ctx.Objects.Setup()
if err == nil {
ctx.Info.Println("objSetup complete, no errors")
} else {
ctx.Info.Panic("objSetup couldn't finish without errors: " + err.Error())
}
}
ctx.Info.Println("Initialization complete")
go http.Start(ctx)
amqp.Start(ctx)
}