-
Notifications
You must be signed in to change notification settings - Fork 11
/
main_darwin.go
59 lines (46 loc) · 1.27 KB
/
main_darwin.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
// +build darwin
package main
import (
"flag"
"net/http"
_ "net/http/pprof"
"runtime"
"runtime/debug"
log "github.com/sirupsen/logrus"
"github.com/aerospike-community/amc/common"
"github.com/aerospike-community/amc/controllers"
)
var (
configFile = flag.String("config-file", "/etc/amc/amc.conf", "Configuration file.")
configDir = flag.String("config-dir", "/etc/amc/", "Configuration dir.")
profileMode = flag.Bool("profile", false, "Run benchmarks with profiler active on port 6060.")
daemonMode = flag.Bool("daemon", false, "Run AMC in daemon mode.")
daemonSignal = flag.String("signal", "", `send signal to the daemon
stop — graceful shutdown.`)
)
func main() {
defer func() {
if err := recover(); err != nil {
log.Fatal(string(debug.Stack()))
}
}()
runtime.GOMAXPROCS(runtime.NumCPU())
flag.Parse()
// launch profiler if in profile mode
if *profileMode {
go func() {
log.Println(http.ListenAndServe(":6060", nil))
}()
}
log.Infof("Trying to start the AMC server...")
config := common.Config{}
common.InitConfig(*configFile, *configDir, &config)
// close the log file on exit
defer func() {
if config.LogFile != nil {
config.LogFile.Close()
}
}()
common.SetupDatabase(config.AMC.Database)
controllers.Server(&config)
}