-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathprofiler.go
More file actions
47 lines (37 loc) · 929 Bytes
/
profiler.go
File metadata and controls
47 lines (37 loc) · 929 Bytes
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
package main
import (
"flag"
"os"
"time"
"github.com/go-resty/resty"
"github.com/golang/glog"
"github.com/spf13/viper"
)
// Run start the web server
func Run(fileConfig string) error {
viper := viper.New()
viper.SetConfigType("json")
if fileConfig == "" {
viper.SetConfigName("config")
viper.AddConfigPath("/etc/workload-profiler")
viper.Set("awsId", os.Getenv("AWS_ACCESS_KEY_ID"))
viper.Set("awsSecret", os.Getenv("AWS_SECRET_ACCESS_KEY"))
} else {
viper.SetConfigFile(fileConfig)
}
viper.SetDefault("port", "7779")
err := viper.ReadInConfig()
if err != nil {
return err
}
resty.SetTimeout(time.Duration(3 * time.Minute))
resty.SetRedirectPolicy(resty.FlexibleRedirectPolicy(10))
server := NewServer(viper)
return server.StartServer()
}
func main() {
configPath := flag.String("config", "", "The file path to a config file")
flag.Parse()
err := Run(*configPath)
glog.Errorln(err)
}