WaitForSqlServerToStart polls the specified database to wait for it to become available, pausing between retry attempts, and returning an error if it is not able to verify that the database is available.
(database *sqlx.DB)
| 169 | require.NoError(t, err) |
| 170 | time.Sleep(250 * time.Millisecond) |
| 171 | } |
| 172 | |
| 173 | // WaitForSqlServerToStart polls the specified database to wait for it to become available, pausing |
| 174 | // between retry attempts, and returning an error if it is not able to verify that the database is |
| 175 | // available. |
| 176 | func WaitForSqlServerToStart(database *sqlx.DB) error { |
| 177 | fmt.Printf("Waiting for server to start...\n") |
| 178 | for counter := 0; counter < 50; counter++ { |
| 179 | if database.Ping() == nil { |
| 180 | return nil |
| 181 | } |
| 182 | fmt.Printf("not up yet; waiting...\n") |
| 183 | time.Sleep(500 * time.Millisecond) |
| 184 | } |
| 185 |
no outgoing calls