oc-discovery/main.go

45 lines
1.4 KiB
Go
Raw Normal View History

2023-03-07 13:29:08 +01:00
package main
import (
2023-03-09 11:45:29 +01:00
"oc-discovery/models"
2023-03-07 13:29:08 +01:00
_ "oc-discovery/routers"
2024-09-02 17:52:12 +02:00
oclib "cloud.o-forge.io/core/oc-lib"
"cloud.o-forge.io/core/oc-lib/logs"
"cloud.o-forge.io/core/oc-lib/tools"
2023-03-07 13:29:08 +01:00
beego "github.com/beego/beego/v2/server/web"
)
2024-09-02 17:52:12 +02:00
const appname = "oc-discovery"
2023-03-09 11:45:29 +01:00
2023-03-07 13:29:08 +01:00
func main() {
2024-09-02 17:52:12 +02:00
// Init the oc-lib
oclib.Init(appname, "", "")
// get the right config file
o := tools.GetConfLoader()
2023-03-09 11:45:29 +01:00
2024-09-02 17:52:12 +02:00
models.GetConfig().Port = o.GetIntDefault("port", 8080)
models.GetConfig().LokiUrl = o.GetStringDefault("lokiurl", "")
2023-03-09 11:45:29 +01:00
models.GetConfig().RedisUrl = o.GetStringDefault("redisurl", "localhost:6379")
models.GetConfig().RedisPassword = o.GetStringDefault("redispassword", "")
models.GetConfig().ZincUrl = o.GetStringDefault("zincurl", "http://localhost:4080")
models.GetConfig().ZincLogin = o.GetStringDefault("zinclogin", "admin")
models.GetConfig().ZincPassword = o.GetStringDefault("zincpassword", "admin")
2023-10-18 11:08:10 +02:00
models.GetConfig().IdentityFile = o.GetStringDefault("identityfile", "./identity.json")
2023-03-09 11:45:29 +01:00
models.GetConfig().Defaultpeers = o.GetStringDefault("defaultpeers", "./peers.json")
2024-09-02 17:52:12 +02:00
// set oc-lib logger
if models.GetConfig().LokiUrl != "" {
logs.CreateLogger(appname, models.GetConfig().LokiUrl)
}
2023-03-09 11:45:29 +01:00
// Normal beego init
2024-09-02 17:52:12 +02:00
beego.BConfig.AppName = appname
beego.BConfig.Listen.HTTPPort = models.GetConfig().Port
2023-10-18 15:24:57 +02:00
beego.BConfig.WebConfig.DirectoryIndex = true
beego.BConfig.WebConfig.StaticDir["/swagger"] = "swagger"
2024-09-02 17:52:12 +02:00
2023-03-07 13:29:08 +01:00
beego.Run()
}