Revert "Revert "V0.4.0 imporve error response""

This reverts commit 9744f45e86.
This commit is contained in:
yaziming
2019-09-04 20:41:37 +08:00
parent bb4ec17125
commit 6dc687192e
51 changed files with 1373 additions and 416 deletions

View File

@@ -3,6 +3,7 @@ package database
import (
"github.com/globalsign/mgo"
"github.com/spf13/viper"
"time"
)
var Session *mgo.Session
@@ -44,7 +45,7 @@ func InitMongo() error {
} else {
uri = "mongodb://" + mongoUsername + ":" + mongoPassword + "@" + mongoHost + ":" + mongoPort + "/" + mongoDb + "?authSource=" + mongoAuth
}
sess, err := mgo.Dial(uri)
sess, err := mgo.DialWithTimeout(uri, time.Second*5)
if err != nil {
return err
}