update default conf

This commit is contained in:
lealife
2015-10-07 00:28:35 +08:00
parent 8b3a1a646a
commit a0088ead9e
2 changed files with 12 additions and 4 deletions

View File

@ -65,9 +65,15 @@ func Init(url, dbname string) {
url, ok = config.String("db.url")
if !ok {
url, ok = config.String("db.urlEnv")
if ok {
Log("get db conf from urlEnv: " + url)
}
} else {
Log("get db conf from db.url: " + url)
}
if ok {
// get dbname from url
// get dbname from urlEnv
urls := strings.Split(url, "/")
dbname = urls[len(urls)-1]
}
@ -75,6 +81,8 @@ func Init(url, dbname string) {
if dbname == "" {
dbname, _ = config.String("db.dbname")
}
// get db config from host, port, username, password
if !ok {
host, _ := revel.Config.String("db.host")
port, _ := revel.Config.String("db.port")

View File

@ -15,10 +15,10 @@ db.port=27017
db.dbname=leanote # required
db.username= # if not exists, please leave it blank
db.password= # if not exists, please leave it blank
# or you can set the mongdb url for more complex needs the format is:
# or you can set the mongodb 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
# db.urlEnv=${MONGODB_URL} # set url from env
# You Must Change It !! About Security!!
app.secret=V85ZzBeTnzpsHyjQX4zukbQ8qqtju9y2aDM55VWxAH9Qop19poekx3xkcDVvrD0y
@ -32,7 +32,7 @@ http.addr=
http.ssl=false
cookie.httponly=false
cookie.prefix=LEANOTE
cookie.domain= # for share cookie with subdomain, 默认为空, 即不设置 不能设置为localhost, 要么就为空
cookie.domain= # for share cookie with sub-domain
cookie.secure=false
format.date=01/02/2006
format.datetime=01/02/2006 15:04