fix(docker): surface backend crash logs in docker logs and print DB target
Build and Deploy / build-and-push (push) Successful in 52s

This commit is contained in:
2026-07-26 15:20:56 +08:00
parent afe7833539
commit 472b956203
4 changed files with 51 additions and 15 deletions
+10
View File
@@ -133,7 +133,17 @@ func (a *App) initDatabase() {
SSLMode: a.Config.Database.SSLMode,
}
// 启动期打印有效 DB 配置(不含密码),便于 Docker 排查
if dbCfg.Type == "sqlite" {
logger.Infof("[Database] 使用 sqlite path=%s", dbCfg.Path)
} else {
logger.Infof("[Database] 使用 %s host=%s port=%d user=%s dbname=%s",
dbCfg.Type, dbCfg.Host, dbCfg.Port, dbCfg.User, dbCfg.DBName)
}
if err := database.Init(dbCfg); err != nil {
logger.Errorf("Failed to init database: %v", err)
logger.Errorf("排查建议: 1) 确认 BH_DB_* 环境变量已注入 2) MySQL 是否允许 host.docker.internal 访问 3) configs/config.ini 是否覆盖了错误配置")
logger.Fatalf("Failed to init database: %v", err)
}