Skip to content

Commit

Permalink
fix: Add debug logging for connecting to psql (#5078)
Browse files Browse the repository at this point in the history
If a database connection hung, the output was unclear.
  • Loading branch information
kylecarbs committed Nov 15, 2022
1 parent 50b5bec commit 773fc73
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions cli/server.go
Original file line number Diff line number Diff line change
Expand Up @@ -425,6 +425,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
options.Database = databasefake.New()
options.Pubsub = database.NewPubsubInMemory()
} else {
logger.Debug(ctx, "connecting to postgresql")
sqlDB, err := sql.Open(sqlDriver, cfg.PostgresURL.Value)
if err != nil {
return xerrors.Errorf("dial postgres: %w", err)
Expand All @@ -448,6 +449,7 @@ func Server(vip *viper.Viper, newAPI func(context.Context, *coderd.Options) (*co
if semver.Compare("v"+versionStr, "v13") < 0 {
return xerrors.New("PostgreSQL version must be v13.0.0 or higher!")
}
logger.Debug(ctx, "connected to postgresql", slog.F("version", versionStr))

err = sqlDB.Ping()
if err != nil {
Expand Down

0 comments on commit 773fc73

Please sign in to comment.