title: Curl retry mechanism
body: <p>I have a script I run to deploy two web services and a front-end application. The script calls a method that checks to see if the two back-end services are up and running. If so, deem the deploy successful, otherwise revert.</p>
  <p>The two services sometimes take longer than the front-end to start up. Currently, I put in a sleep call to delay the web service check. This allows them time to start up.</p>
  <p>I want to remove this sleep and add in a retry mechanism so that if a service is down, just retry the check repeatedly until I get a response.</p>
  <p>To check if the device is up, I use <a href="https://en.wikipedia.org/wiki/CURL" rel="nofollow noreferrer">curl</a>. I've read that curl has a retry mechanism but I've never used it.</p>
  <p>Have any of you solved this problem before? I want to understand the things I must consider when solving it, e.g. do I retry until I get an HTTP 200 response from my service?</p>
  <p>Does anyone have any suggestions on how I'd test this? I'd need to find a service that was down.</p>
  <p>EDIT: I see that <code>-retry</code> only reacts to transient errors. &quot;Transient error means either: a timeout, an FTP 4xx response code or an HTTP 5xx response code&quot;. My service can return a 404 therefore curl's retry is not my solution.</p>