| 441 | } |
| 442 | |
| 443 | func (s cloud) awaitPostgres(ctx context.Context, preset string) error { |
| 444 | logInfo.Printf("Waiting for Postgres (%s)\n", preset) |
| 445 | |
| 446 | dbURL := lookupDotenv("RILL_ADMIN_DATABASE_URL") |
| 447 | for { |
| 448 | conn, err := pgx.Connect(ctx, dbURL) |
| 449 | if err == nil { |
| 450 | conn.Close(ctx) |
| 451 | logInfo.Printf("Postgres ready at %s\n", dbURL) |
| 452 | return nil |
| 453 | } |
| 454 | |
| 455 | select { |
| 456 | case <-time.After(1 * time.Second): |
| 457 | case <-ctx.Done(): |
| 458 | return ctx.Err() |
| 459 | } |
| 460 | } |
| 461 | } |
| 462 | |
| 463 | func (s cloud) awaitRedis(ctx context.Context) error { |
| 464 | dbURL := lookupDotenv("RILL_ADMIN_REDIS_URL") |