Modified DCName and DBPoint retrieving
This commit is contained in:
parent
67d36b533f
commit
c8508a4976
4
main.go
4
main.go
@ -27,6 +27,8 @@ func main() {
|
||||
routers.Init()
|
||||
services.Init()
|
||||
|
||||
beego.BConfig.RunMode = "dev"
|
||||
|
||||
// if beego.BConfig.RunMode == "dev" {
|
||||
// // beego.BConfig.WebConfig.DirectoryIndex = true
|
||||
beego.BConfig.WebConfig.DirectoryIndex = true
|
||||
@ -71,7 +73,7 @@ func loadConfig(){
|
||||
o = onion.New(l1, l3)
|
||||
}
|
||||
|
||||
conf.GetConfig().MongoURL = o.GetStringDefault("MongoURL", "mongodb://127.0.0.1:27017/beego-demo")
|
||||
conf.GetConfig().MongoURL = o.GetStringDefault("MongoURL", "mongodb://127.0.0.1:27017")
|
||||
conf.GetConfig().DCNAME = o.GetStringDefault("DCNAME", "DC_myDC")
|
||||
conf.GetConfig().DBPOINT = o.GetStringDefault("DBPOINT", "demdemo_06042021o")
|
||||
|
||||
|
@ -79,8 +79,6 @@ func Init() {
|
||||
),
|
||||
)
|
||||
|
||||
// Namespace containing useful Path such as ping
|
||||
|
||||
|
||||
beego.AddNamespace(ns)
|
||||
|
||||
|
@ -1,29 +1,44 @@
|
||||
package services
|
||||
|
||||
import (
|
||||
"os"
|
||||
"cloud.o-forge.io/core/oc-catalog/conf"
|
||||
|
||||
"github.com/beego/beego/v2/core/logs"
|
||||
beego "github.com/beego/beego/v2/server/web"
|
||||
)
|
||||
|
||||
func Init() {
|
||||
Discoveryinit() //First init DC name
|
||||
// Discoveryinit() //First init DC name
|
||||
|
||||
config := conf.GetConfig()
|
||||
|
||||
var DBpoint string
|
||||
var DC_NAME string
|
||||
var err error
|
||||
|
||||
DC_NAME = config.DCNAME
|
||||
|
||||
DBpoint = os.Getenv("DOCKER_DBPOINT")
|
||||
if len(DBpoint) == 0 {
|
||||
DBpoint, err = beego.AppConfig.String("DBPOINT")
|
||||
if err != nil {
|
||||
logs.Critical("DBPOINT URI error: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
if len(DC_NAME) == 0 {
|
||||
logs.Critical("DC_NAME URI error: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
DBpoint = config.DBPOINT
|
||||
|
||||
if len(DBpoint) == 0 {
|
||||
logs.Critical("DBPOINT URI error: %v", err)
|
||||
panic(err)
|
||||
}
|
||||
|
||||
|
||||
// if len(DBpoint) == 0 {
|
||||
// DBpoint, err = beego.AppConfig.String("DBPOINT")
|
||||
// if err != nil {
|
||||
// logs.Critical("DBPOINT URI error: %v", err)
|
||||
// panic(err)
|
||||
// }
|
||||
// }
|
||||
|
||||
logs.Debug("connecting to datacenter db : " + DC_NAME + "-" + DBpoint)
|
||||
Mongoinit(DC_NAME + "-" + DBpoint)
|
||||
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user