db connection lost #222
This commit is contained in:
@ -355,3 +355,20 @@ func Err(err error) bool {
|
|||||||
}
|
}
|
||||||
return true
|
return true
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// 检查mognodb是否lost connection
|
||||||
|
// 每个请求之前都要检查!!
|
||||||
|
func CheckMongoSessionLost() {
|
||||||
|
// fmt.Println("检查CheckMongoSessionLostErr")
|
||||||
|
err := Session.Ping()
|
||||||
|
if err != nil {
|
||||||
|
Log("Lost connection to db!")
|
||||||
|
Session.Refresh()
|
||||||
|
err = Session.Ping()
|
||||||
|
if err == nil {
|
||||||
|
Log("Reconnect to db successful.")
|
||||||
|
} else {
|
||||||
|
Log("重连失败!!!! 警告")
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@ -2,7 +2,7 @@ package route
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"github.com/revel/revel"
|
"github.com/revel/revel"
|
||||||
// "github.com/leanote/leanote/app/service"
|
"github.com/leanote/leanote/app/db"
|
||||||
// . "github.com/leanote/leanote/app/lea"
|
// . "github.com/leanote/leanote/app/lea"
|
||||||
"net/url"
|
"net/url"
|
||||||
"strings"
|
"strings"
|
||||||
@ -42,6 +42,10 @@ func RouterFilter(c *revel.Controller, fc []revel.Filter) {
|
|||||||
}
|
}
|
||||||
*/
|
*/
|
||||||
if route.ControllerName != "Static" {
|
if route.ControllerName != "Static" {
|
||||||
|
|
||||||
|
// 检查mongodb 是否lost
|
||||||
|
db.CheckMongoSessionLost()
|
||||||
|
|
||||||
// api设置
|
// api设置
|
||||||
// leanote.com/api/user/get => ApiUser::Get
|
// leanote.com/api/user/get => ApiUser::Get
|
||||||
//* /api/login ApiAuth.Login, 这里的设置, 其实已经转成了ApiAuth了
|
//* /api/login ApiAuth.Login, 这里的设置, 其实已经转成了ApiAuth了
|
||||||
|
Reference in New Issue
Block a user