fix: 修复 Docker Compose 环境下 PostgreSQL 连接失败

This commit is contained in:
hhs
2026-06-14 20:47:00 +08:00
parent 9dc9025d10
commit 1ddd75d34f
3 changed files with 12 additions and 1 deletions

View File

@@ -56,6 +56,10 @@ func main() {
var sessRepo store.SessionRepository
if cfg.Storage.Driver == "postgres" {
if cfg.Storage.DSN == "" {
logger.Log.Fatalw("storage.dsn is required when storage.driver is postgres",
"hint", "set CAMTALK_STORAGE_DSN environment variable")
}
pool, err := store.NewPostgresPool(ctx, cfg.Storage.DSN)
if err != nil {
logger.Log.Fatalw("failed to connect to postgres", "error", err)

View File

@@ -152,6 +152,7 @@ func Load() (*Config, error) {
v.SetDefault("ai.tts.output_format", "mp3")
v.SetDefault("ai.tts.sample_rate", 24000)
v.SetDefault("storage.driver", "memory")
v.SetDefault("storage.dsn", "")
v.SetDefault("log.level", "info")
v.SetDefault("log.format", "console")
v.SetDefault("auth.access_ttl", 15)