-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmain.go
More file actions
77 lines (59 loc) · 1.72 KB
/
main.go
File metadata and controls
77 lines (59 loc) · 1.72 KB
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
62
63
64
65
66
67
68
69
70
71
package main
import (
"flag"
"os"
"strings"
cassieConf "github.com/cloudurable/cassandra-cloud/impl"
lg "github.com/advantageous/go-logback/logging"
)
func main() {
debug, configFilename, logger := initialCommandLineParse()
config, err := cassieConf.LoadConfig(configFilename, debug, logger)
if err != nil {
logger.Errorf("Unable to load config filename %s \n", configFilename)
logger.ErrorError("Error was", err)
os.Exit(1)
}
cassieConf.ProcessTemplate(config.YamlConfigTemplate, config.YamlConfigFileName, config, logger)
cassieConf.ProcessTemplate(config.JvmOptionsTemplate, config.JvmOptionsFileName, config, logger)
}
func initialCommandLineParse() (bool, string, lg.Logger) {
flag.Bool("debug", false, "Turn on debugging")
flag.String("config", "", "Location of config file")
var debug bool
var configFilename string
foundIndex := -1
for index, arg := range os.Args {
if arg == "-debug" {
debug = true
} else if strings.HasPrefix(arg, "-debug=") {
debug = true
} else if arg == "-config" {
foundIndex = index
} else if strings.HasPrefix(arg, "-config=") {
split := strings.Split(arg, "=")
configFilename = split[1]
}
}
if foundIndex != -1 {
configFilename = os.Args[foundIndex+1]
}
var logger lg.Logger
if debug {
logger = lg.NewSimpleDebugLogger("cassandra-cloud")
} else {
logger = lg.NewSimpleLogger("cassandra-cloud")
}
if configFilename == "" {
configFilename = os.Getenv("CASSANDRA_CLOUD_CONFIG")
}
if configFilename == "" {
cassandraHome := os.Getenv("CASSANDRA_HOME")
if cassandraHome == "" {
configFilename = "/opt/cassandra/conf/cloud.conf"
} else {
configFilename = cassandraHome + "/conf/cloud.conf"
}
}
return debug, configFilename, logger
}