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