[FIX]修改配置文件

This commit is contained in:
viletyy 2020-09-26 13:34:54 +08:00
parent 458672acd1
commit 5010beb901
3 changed files with 38 additions and 27 deletions

View File

@ -1,19 +1,29 @@
RUN_MODE = debug
[app] [app]
PAGE_SIZE = 10 PageSize = 10
JWT_SECRET = 23347$040412 JwtSecret = 233
RuntimeRootPath = runtime/
ImagePrefixUrl = http://127.0.0.8002
ImageSavePath = upload/images/
ImageMaxSize = 5
ImageAllowExts = .jpg,.jpeg,.png
logSavePath = logs/
LogSaveName = log
LogFileExt = log
TimeFormat = 20060102
[server] [server]
HTTP_PORT = 8002 RunMode = debug
READ_TIMEOUT = 60 HttpPort = 8002
WRITE_TIMEOUT = 60 ReadTimeout = 60
WriteTimeout = 60
[database] [database]
TYPE = postgres Type = postgres
USER = virus User = virus
PASSWORD = a19960425 Password = a19960425
HOST = 0.0.0.0 Host = 0.0.0.0
PORT = 5432 Port = 5432
NAME = shop Name = shop
TABLE_PREFIX = shop_ TablePrefix = shop_

View File

@ -29,13 +29,13 @@ func init() {
log.Fatal(2, "Fail to get section 'database': %v", err) log.Fatal(2, "Fail to get section 'database': %v", err)
} }
dbType = sec.Key("TYPE").String() dbType = sec.Key("Type").String()
dbName = sec.Key("NAME").String() dbName = sec.Key("Name").String()
user = sec.Key("USER").String() user = sec.Key("User").String()
password = sec.Key("PASSWORD").String() password = sec.Key("Password").String()
host = sec.Key("HOST").String() host = sec.Key("Host").String()
port = sec.Key("PORT").String() port = sec.Key("Port").String()
tablePrefix = sec.Key("TABLE_PREFIX").String() tablePrefix = sec.Key("TablePrefix").String()
db, err = gorm.Open(dbType, fmt.Sprintf("host=%s user=%s dbname=%s port=%s sslmode=disable password=%s", db, err = gorm.Open(dbType, fmt.Sprintf("host=%s user=%s dbname=%s port=%s sslmode=disable password=%s",
host, host,

View File

@ -29,7 +29,7 @@ func init() {
} }
func LoadBase() { func LoadBase() {
RunMode = Cfg.Section("").Key("RUN_MODE").MustString("debug") //RunMode = Cfg.Section("server").Key("RUN_MODE").MustString("debug")
} }
func LoadServer() { func LoadServer() {
@ -38,9 +38,10 @@ func LoadServer() {
log.Fatalf("Fail to get section 'sever' : %v", err) log.Fatalf("Fail to get section 'sever' : %v", err)
} }
HTTPPort = sec.Key("HTTP_PORT").MustInt(8000) RunMode = sec.Key("RunMode").MustString("debug")
ReadTimeout = time.Duration(sec.Key("READ_TIMEOUT").MustUint(60)) * time.Second HTTPPort = sec.Key("HttpPort").MustInt(8000)
WriteTimeout = time.Duration(sec.Key("WRITE_TIMEOUT").MustInt(60)) * time.Second ReadTimeout = time.Duration(sec.Key("ReadTimeout").MustUint(60)) * time.Second
WriteTimeout = time.Duration(sec.Key("WriteTimeout").MustInt(60)) * time.Second
} }
func LoadApp() { func LoadApp() {
@ -49,6 +50,6 @@ func LoadApp() {
log.Fatalf("Fail to get section 'app':%v", err) log.Fatalf("Fail to get section 'app':%v", err)
} }
JwtSecret = sec.Key("JWT_SECRET").MustString("!@#!@#!@#!@@#!@#") JwtSecret = sec.Key("JwtSecret").MustString("!@#!@#!@#!@@#!@#")
PageSize = sec.Key("PAGE_SIZE").MustInt(10) PageSize = sec.Key("WriteTimeout").MustInt(10)
} }