|
|
@@ -2,12 +2,13 @@ package engine
|
|
|
|
|
|
import (
|
|
|
"fmt"
|
|
|
+ "regexp"
|
|
|
+ "time"
|
|
|
+
|
|
|
"git.qianqiusoft.com/qianqiusoft/light-apiengine/logs"
|
|
|
"git.qianqiusoft.com/qianqiusoft/light-apiengine/models"
|
|
|
"git.qianqiusoft.com/qianqiusoft/light-apiengine/utils"
|
|
|
"github.com/xormplus/xorm"
|
|
|
- "regexp"
|
|
|
- "time"
|
|
|
)
|
|
|
|
|
|
func createDatabase(orm *xorm.Engine) {
|
|
|
@@ -21,6 +22,8 @@ func createDatabase(orm *xorm.Engine) {
|
|
|
dbname = strings[2]
|
|
|
db, _ := xorm.NewEngine(orm.DriverName(), strings[1]+"/")
|
|
|
db.ShowSQL(true)
|
|
|
+ db.SetConnMaxLifetime(10 * time.Minute)
|
|
|
+ db.SetMaxIdleConns(10)
|
|
|
_, err := db.Sql("CREATE DATABASE IF NOT EXISTS `" + dbname + "` default charset utf8 COLLATE utf8_general_ci").Execute()
|
|
|
if err != nil {
|
|
|
fmt.Println("create database error", err)
|
|
|
@@ -214,6 +217,8 @@ func initOrmEngine(orm *xorm.Engine, driverName string) {
|
|
|
orm.StartFSWatcher()
|
|
|
|
|
|
orm.ShowSQL(true)
|
|
|
+ orm.SetConnMaxLifetime(10 * time.Minute)
|
|
|
+ orm.SetMaxIdleConns(10)
|
|
|
/*for k,_:=range orm.SqlMap.Sql{
|
|
|
fmt.Println(k)
|
|
|
}*/
|