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