parent
f7cf741b54
commit
4ce1b2956b
|
@ -2,7 +2,7 @@ api-gen:
|
|||
goctl api go -api desc/pcm.api -dir . -style gozero --home ../deploy/goctl
|
||||
|
||||
Generate-AMD64:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-coordinator-api pcm-coordinator-api pcm.go
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=amd64 go build -o pcm-coordinator-api pcm.go
|
||||
|
||||
Generate-ARM64:
|
||||
CGO_ENABLED=0 GOOS=linux GOARCH=arm64 GOARM=7 go build -o pcm-coordinator-api pcm.go
|
||||
|
|
|
@ -39,6 +39,7 @@ import (
|
|||
"gorm.io/driver/mysql"
|
||||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/schema"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
|
@ -84,6 +85,16 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||
SingularTable: true, // 使用单数表名,启用该选项,此时,`User` 的表名应该是 `t_user`
|
||||
},
|
||||
})
|
||||
sqlDB, err := dbEngin.DB()
|
||||
// SetMaxIdleConns 设置空闲连接池中连接的最大数量
|
||||
sqlDB.SetMaxIdleConns(10)
|
||||
|
||||
// SetMaxOpenConns 设置打开数据库连接的最大数量。
|
||||
sqlDB.SetMaxOpenConns(50)
|
||||
|
||||
// SetConnMaxLifetime 设置了连接可复用的最大时间。
|
||||
sqlDB.SetConnMaxLifetime(time.Hour)
|
||||
|
||||
dockerClient, err := client.NewClientWithOpts()
|
||||
if err != nil {
|
||||
logx.Error(err.Error())
|
||||
|
|
|
@ -25,6 +25,7 @@ import (
|
|||
"gorm.io/gorm"
|
||||
"gorm.io/gorm/logger"
|
||||
"gorm.io/gorm/schema"
|
||||
"time"
|
||||
)
|
||||
|
||||
type ServiceContext struct {
|
||||
|
@ -42,8 +43,17 @@ func NewServiceContext(c config.Config) *ServiceContext {
|
|||
},
|
||||
Logger: logger.Default.LogMode(logger.Warn),
|
||||
})
|
||||
sqlDB, err := dbEngin.DB()
|
||||
// SetMaxIdleConns 设置空闲连接池中连接的最大数量
|
||||
sqlDB.SetMaxIdleConns(10)
|
||||
|
||||
// SetMaxOpenConns 设置打开数据库连接的最大数量。
|
||||
sqlDB.SetMaxOpenConns(50)
|
||||
|
||||
// SetConnMaxLifetime 设置了连接可复用的最大时间。
|
||||
sqlDB.SetConnMaxLifetime(time.Hour)
|
||||
//添加snowflake支持
|
||||
err := utils.InitSnowflake(c.SnowflakeConf.MachineId)
|
||||
err = utils.InitSnowflake(c.SnowflakeConf.MachineId)
|
||||
if err != nil {
|
||||
logx.Errorf("InitSnowflake err: ", err)
|
||||
panic("InitSnowflake err")
|
||||
|
|
Loading…
Reference in New Issue