fix(config): handle missing config file and middleware directory gracefully and log a warning

This commit is contained in:
yusing
2025-09-02 17:20:24 +08:00
parent 4513c221d5
commit 6a3e28dfd7
2 changed files with 12 additions and 1 deletions

View File

@@ -220,7 +220,13 @@ func (cfg *Config) load() gperr.Error {
data, err := os.ReadFile(common.ConfigPath)
if err != nil {
gperr.LogFatal(errMsg, err)
if os.IsNotExist(err) {
log.Warn().Msg("config file not found, using default config")
cfg.value = config.DefaultConfig()
return nil
} else {
gperr.LogFatal(errMsg, err)
}
}
model := config.DefaultConfig()