Created
November 16, 2015 18:48
-
-
Save jgraham909/db3f597a791f8685e204 to your computer and use it in GitHub Desktop.
One line retry with exponential backoff
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# Currently runs "make deploy" just change that to whatever you want | |
(MAXTRIES=4; COUNT=0; BACKOFF=1; while [ $COUNT -lt $MAXTRIES ]; do (make deploy); if [ $? -eq 0 ];then exit 0; fi; let COUNT=COUNT+1; let BACKOFF=BACKOFF*2; echo "Attempt $COUNT failed retrying after $BACKOFF seconds"; sleep $BACKOFF; done; echo "Tried and failed $COUNT times. Giving up."; exit 1;) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
See also https://gist.github.com/jgraham909/592615563f7c197b462f