-
Notifications
You must be signed in to change notification settings - Fork 1
/
main.go
46 lines (38 loc) · 1.15 KB
/
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
44
45
46
package main
import (
"github.com/gin-gonic/gin"
"github.com/spf13/viper"
"kok/models"
"kok/pkg/control"
"kok/routers"
"os"
)
func init() {
viper.SetDefault("GIN_MODE", "debug")
viper.SetDefault("GIN_HOST", ":8080")
viper.SetDefault("JWT_TOKEN", "secret")
viper.SetDefault("DB_URL", "./data/kok.sqlite")
viper.SetDefault("DB_TYPE", "sqlite")
viper.SetDefault("ISTIO_INJECTION", "enabled") // enabled or disable
viper.SetDefault("PROMETHEUS_URL", "http://prometheus.kok.svc:9090")
viper.SetDefault("ELASTICSEARCH_URL", "http://elasticsearch.kok.svc:9200")
viper.SetDefault("AppMarket_URL", "https://buxiaomo.github.io/appmarket/")
viper.AutomaticEnv()
if _, err := os.Stat("./data"); err != nil {
os.Mkdir("./data", 0755)
}
if _, err := os.Stat("./data/kubeconfig"); err != nil {
os.Mkdir("./data/kubeconfig", 0755)
}
kc := control.New("")
if !kc.HasDefaultSC() {
panic("cluster not has default storageclass!")
}
//go kc.ClearPodOnFaultyNode()
models.ConnectDB(viper.GetString("DB_TYPE"), viper.GetString("DB_URL"))
}
func main() {
gin.SetMode(viper.GetString("GIN_MODE"))
r := routers.SetupRouter()
r.Run(viper.GetString("GIN_HOST"))
}