Skip to content

Commit 773fc73

Browse files
authored
fix: Add debug logging for connecting to psql (#5078)
If a database connection hung, the output was unclear.
1 parent 50b5bec commit 773fc73

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

cli/server.go

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -425,6 +425,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
425425
options.Database = databasefake.New()
426426
options.Pubsub = database.NewPubsubInMemory()
427427
} else {
428+
logger.Debug(ctx, "connecting to postgresql")
428429
sqlDB, err := sql.Open(sqlDriver, cfg.PostgresURL.Value)
429430
if err != nil {
430431
return xerrors.Errorf("dial postgres: %w", err)
@@ -448,6 +449,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
448449
if semver.Compare("v"+versionStr, "v13") < 0 {
449450
return xerrors.New("PostgreSQL version must be v13.0.0 or higher!")
450451
}
452+
logger.Debug(ctx, "connected to postgresql", slog.F("version", versionStr))
451453

452454
err = sqlDB.Ping()
453455
if err != nil {

0 commit comments

Comments
 (0)