Retry connecting to database on startup.