opt: 优化启动参数接收处理

This commit is contained in:
RockYang 2023-06-28 05:51:55 +08:00
parent daf83cfc84
commit 6c65a21692
2 changed files with 11 additions and 1 deletions

View File

@ -108,6 +108,7 @@ func sessionMiddleware(config *types.AppConfig) gin.HandlerFunc {
store = cookie.NewStore([]byte(config.Session.SecretKey))
break
default:
config.Session.Driver = types.SessionDriverCookie
store = cookie.NewStore([]byte(config.Session.SecretKey))
}

View File

@ -45,7 +45,16 @@ func (l *AppLifecycle) OnStop(context.Context) error {
func main() {
configFile := os.Getenv("CONFIG_FILE")
debug, _ := strconv.ParseBool(os.Getenv("DEBUG"))
if configFile == "" {
configFile = "config.toml"
}
var debug bool
debugEnv := os.Getenv("DEBUG")
if debugEnv == "" {
debug = true
} else {
debug, _ = strconv.ParseBool(os.Getenv("DEBUG"))
}
logger.Info("Loading config file: ", configFile)
defer func() {
if err := recover(); err != nil {