-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathmain.go
43 lines (37 loc) · 824 Bytes
/
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
package main
import (
"agent/agent"
"agent/config"
"agent/logger"
"flag"
"os"
_ "github.com/heroku/x/hmetrics/onload"
"github.com/joho/godotenv"
)
func main() {
flag.Bool("help", false, "Help flag")
var testFlag = flag.Bool("test", false, "Flag to test postgres monitor agent setup")
var testLogsFlag = flag.Bool("test-logs", false, "Flag to test postgres logs setup")
var devFlag = flag.Bool("dev", false, "Flag to toggle dev mode")
flag.Parse()
if *devFlag {
// load .env file
err := godotenv.Load()
if err != nil {
logger.Error("Error loading .env file")
os.Exit(1)
}
}
config := config.New()
if *testFlag || *testLogsFlag {
config.SetTestMode()
}
agent := agent.New(config)
if *testFlag {
agent.Test()
} else if *testLogsFlag {
agent.TestLogs()
} else {
agent.Run()
}
}