This commit is contained in:
新亮
2021-04-18 19:54:31 +08:00
parent 3e1ef9c658
commit 1f85d8df61
64 changed files with 1356 additions and 2758 deletions

View File

@@ -6,6 +6,7 @@ import (
"github.com/xinliangnote/go-gin-api/pkg/env"
"github.com/fsnotify/fsnotify"
"github.com/spf13/viper"
)
@@ -77,6 +78,13 @@ func init() {
if err := viper.Unmarshal(config); err != nil {
panic(err)
}
viper.WatchConfig()
viper.OnConfigChange(func(e fsnotify.Event) {
if err := viper.Unmarshal(config); err != nil {
panic(err)
}
})
}
func Get() Config {
@@ -95,6 +103,6 @@ func ProjectLogFile() string {
return fmt.Sprintf("./logs/%s-access.log", ProjectName())
}
func InitDBLockFile() string {
return "cmd/init/db/init_db.lock"
func ProjectInstallFile() string {
return "INSTALL.lock"
}

View File

@@ -1,3 +1 @@
[db]
host = '127.0.0.1'
port = 3306

View File

@@ -1,43 +1,46 @@
[mysql]
[mysql.read] # 从库信息,可读
addr = '127.0.0.1:3306' # MySQL 地址:端口
user = 'root' # 用户名
pass = 'root' # 密码
name = 'go_gin_api' # 数据库名称
[mysql.write] # 主库信息,可读写
addr = '127.0.0.1:3306' # MySQL 地址:端口
user = 'root' # 用户名
pass = 'root' # 密码
name = 'go_gin_api' # 数据库名称
[mysql.base] # 基础配置
maxOpenConn = 10 # 最大打开的连接数
maxIdleConn = 60 # 闲置的连接数
connMaxLifeTime = 60 # 最大连接超时(单位:分)
[redis]
addr = '127.0.0.1:6379' # Redis 地址:端口
pass = '' # 密码
db = 0 # 序号从 0 开始默认是0可以不用设置
maxRetries = 3 # 命令执行失败时,最多重试多少次,默认为 0 即不重试
poolSize = 10 # 连接池最大连接数,默认为 CPU 数 * 10
minIdleConns = 5 # 最小空闲连接数
[mail]
host = 'smtp.163.com' # 邮箱服务器,比如 smtp.163.com
port = 465 # 端口
user = "" # 发件人邮箱
pass = "" # 发件人邮箱密码或授权码,根据邮箱服务器而定
to = "" # 收件人邮箱,多个可以逗号(,)分割
[jwt]
secret = 'i1ydX9RtHyuJTrw7frcu' # JWT secret
expireDuration = 24 # JWT ExpiresAt 过期时间(单位:小时)
[urlToken]
secret = 'i1ydX9RtHyuJTrw7frcu' # URL Token secret
expireDuration = 10 # URL Token ExpiresAt 过期时间(单位:分钟)
[hashids]
secret = '6ab6122836cfef95f8db' # hashids secret
length = 12 # hashids length
length = 12
secret = "6ab6122836cfef95f8db"
[jwt]
expireduration = 24
secret = "i1ydX9RtHyuJTrw7frcu"
[mail]
host = "smtp.163.com"
pass = ""
port = 465
to = ""
user = ""
[mysql]
[mysql.base]
connmaxlifetime = 60
maxidleconn = 60
maxopenconn = 10
[mysql.read]
addr = "127.0.0.1:3306"
name = "go_gin_api"
pass = "root"
user = "root"
[mysql.write]
addr = "127.0.0.1:3306"
name = "go_gin_api"
pass = "root"
user = "root"
[redis]
addr = "127.0.0.1:6379"
db = "0"
maxretries = 3
minidleconns = 5
pass = ""
poolsize = 10
[urltoken]
expireduration = 10
secret = "i1ydX9RtHyuJTrw7frcu"

View File

@@ -1,4 +1,2 @@
[db]
host = '127.0.0.1'
port = 3306

View File

@@ -1,4 +1,2 @@
[db]
host = '127.0.0.1'
port = 3306