+ Timeout

This commit is contained in:
Max 2021-11-23 00:16:24 +08:00
parent c0df8b4b12
commit a8f9b02006
3 changed files with 9 additions and 9 deletions

View file

@ -20,19 +20,17 @@ var startCmd = &cobra.Command{
Long: `启动象传应用引擎`,
Run: func(cmd *cobra.Command, args []string) {
defer service.Stop(func() { fmt.Println("服务已关闭") })
Boot()
mode := config.Conf.Mode
if mode == "debug" {
mode = color.RedString("调试模式")
mode = color.RedString("调试模式\n")
} else {
mode = ""
mode = "\n"
}
fmt.Printf(color.GreenString("\n象传应用引擎 v%s %s", share.VERSION, mode))
fmt.Printf(color.GreenString("象传应用引擎 v%s %s", share.VERSION, mode))
// 加载数据模型 API 等
engine.Load(config.Conf)
engine.Load(config.Conf) // 加载数据模型 API 等
// 打印应用目录信息
fmt.Printf(color.WhiteString("\n---------------------------------"))

View file

@ -5,7 +5,7 @@ import (
)
// VERSION 版本号
const VERSION = "0.9.3"
const VERSION = "0.9.5"
// DOMAIN 许可域
const DOMAIN = "*.iqka.com"

View file

@ -1,6 +1,8 @@
package share
import (
"time"
"github.com/yaoapp/xiang/config"
"github.com/yaoapp/xun/capsule"
)
@ -10,7 +12,7 @@ func DBConnect(dbconfig config.DatabaseConfig) {
// 连接主库
for i, dsn := range dbconfig.Primary {
db := capsule.AddConn("primary", dbconfig.Driver, dsn)
db := capsule.AddConn("primary", dbconfig.Driver, dsn, 5*time.Second)
if i == 0 {
db.SetAsGlobal()
}
@ -18,6 +20,6 @@ func DBConnect(dbconfig config.DatabaseConfig) {
// 连接从库
for _, dsn := range dbconfig.Secondary {
capsule.AddReadConn("secondary", dbconfig.Driver, dsn)
capsule.AddReadConn("secondary", dbconfig.Driver, dsn, 5*time.Second)
}
}