/
gravity-adapter-kafka.go
61 lines (48 loc) · 1.1 KB
/
gravity-adapter-kafka.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
60
61
package main
import (
"fmt"
"os"
"strings"
log "github.com/sirupsen/logrus"
"github.com/spf13/viper"
app "github.com/BrobridgeOrg/gravity-adapter-kafka/pkg/app/instance"
)
func init() {
debugLevel := log.InfoLevel
switch os.Getenv("GRAVITY_DEBUG") {
case log.TraceLevel.String():
debugLevel = log.TraceLevel
case log.DebugLevel.String():
debugLevel = log.DebugLevel
case log.ErrorLevel.String():
debugLevel = log.ErrorLevel
}
log.SetLevel(debugLevel)
fmt.Printf("Debug level is set to \"%s\"\n", debugLevel.String())
// From the environment
viper.SetEnvPrefix("GRAVITY_ADAPTER_KAFKA")
viper.SetEnvKeyReplacer(strings.NewReplacer(".", "_"))
viper.AutomaticEnv()
// From config file
viper.SetConfigName("config")
viper.AddConfigPath("./")
viper.AddConfigPath("./configs")
if err := viper.ReadInConfig(); err != nil {
log.Warn("No configuration file was loaded")
}
}
func main() {
// Initializing application
a := app.NewAppInstance()
err := a.Init()
if err != nil {
log.Fatal(err)
return
}
// Starting application
err = a.Run()
if err != nil {
log.Fatal(err)
return
}
}