get mongodb configuration from env
This commit is contained in:
@ -6,6 +6,7 @@ import (
|
||||
. "github.com/leanote/leanote/app/lea"
|
||||
"gopkg.in/mgo.v2"
|
||||
"gopkg.in/mgo.v2/bson"
|
||||
"strings"
|
||||
)
|
||||
|
||||
// Init mgo and the common DAO
|
||||
@ -62,6 +63,14 @@ func Init(url, dbname string) {
|
||||
config := revel.Config
|
||||
if url == "" {
|
||||
url, ok = config.String("db.url")
|
||||
if !ok {
|
||||
url, ok = config.String("db.urlEnv")
|
||||
}
|
||||
if ok {
|
||||
// get dbname from url
|
||||
urls := strings.Split(url, "/")
|
||||
dbname = urls[len(urls)-1]
|
||||
}
|
||||
}
|
||||
if dbname == "" {
|
||||
dbname, _ = config.String("db.dbname")
|
||||
|
@ -15,6 +15,7 @@ db.password= # if not exists, please leave it blank
|
||||
# or you can set the mongdb url for more complex needs the format is:
|
||||
# mongodb://myuser:mypass@localhost:40001,otherhost:40001/mydb
|
||||
# db.url=mongodb://root:root123@localhost:27017/leanote
|
||||
db.urlEnv=${MONGODB_URL} # set url from env
|
||||
|
||||
# You Must Change It !! About Security!!
|
||||
app.secret=V85ZzBeTnzpsHyjQX4zukbQ8qqtju9y2aDM55VWxAH9Qop19poekx3xkcDVvrD0y
|
||||
|
Reference in New Issue
Block a user