Package: shell-retry
Wrapper for call any utilities with retries until they succeedInstallpipinstallshell-retryExamplesLet’s start from--help:$shell-retry--helpusage:shell-retry[-h][--backoffBACKOFF][--retry-countRETRY_COUNT][--intervalINTERVAL][--verbose]cmd[cmd...]positionalarguments:cmdoptionalarguments:-h,--helpshowthishelpmessageandexit--backoffBACKOFFbackofffactor(sleep(--interval*=--backoff)--retry-countRETRY_COUNTHowmanytimere-runcmdifitfails--intervalINTERVALInitialintervalbetweenretries--interval-maxINTERVAL_MAXupperlimitforinterval--interval-minINTERVAL_MINlowerlimitforinterval--verboseBeverbose,writehowmanyretriesleftandhowlongwillwewaitTo debug something use--verboseflag.--retry-countspecifies retry (not a try) count.--intervalsetsinitialinterval between retries, interval multiplies with backoff before next retry.$shell-retry--verbose--retry-count=5--backoff=1.3false2018-02-2218:23:06,682INFO:Namespace(backoff=1.3,cmd=['false'],interval=1,retry_count=5,verbose=True)2018-02-2218:23:06,683INFO:run['false']2018-02-2218:23:06,687INFO:commandreturned12018-02-2218:23:06,687INFO:waiting1.000000seconds,5retriesleft2018-02-2218:23:07,687INFO:run['false']2018-02-2218:23:07,692INFO:commandreturned12018-02-2218:23:07,692INFO:waiting1.300000seconds,4retriesleft2018-02-2218:23:08,995INFO:run['false']2018-02-2218:23:08,999INFO:commandreturned12018-02-2218:23:08,999INFO:waiting1.690000seconds,3retriesleft2018-02-2218:23:10,690INFO:run['false']2018-02-2218:23:10,696INFO:commandreturned12018-02-2218:23:10,697INFO:waiting2.197000seconds,2retriesleft2018-02-2218:23:12,896INFO:run['false']2018-02-2218:23:12,902INFO:commandreturned12018-02-2218:23:12,903INFO:waiting2.856100seconds,1retriesleft2018-02-2218:23:15,764INFO:run['false']2018-02-2218:23:15,769INFO:commandreturned1To use some flags incmduse--beforecmd.$shell-retry--retry-count=5--backoff=1.2--curl-m1--connect-time1http://10.30.33.32curl:(28)Connectiontimedoutafter1000millisecondscurl:(28)Connectiontimedoutafter1004millisecondscurl:(28)Connectiontimedoutafter1003millisecondscurl:(28)Connectiontimedoutafter1002millisecondscurl:(28)Connectiontimedoutafter1000millisecondscurl:(28)Connectiontimedoutafter1000millisecondsTo limit interval between retries you can use options--interval-maxand--interval-min:$shell-retry--verbose--retry-count=3--backoff=1.2--interval-max=1.2--curl-m1--connect-time1http://10.30.33.322018-02-2219:21:59,170INFO:Namespace(backoff=1.2,cmd=['curl','-m','1','--connect-time','1','http://10.30.33.32'],interval=1,interval_max=1.2,interval_min=None,retry_count=3,verbose=True)2018-02-2219:21:59,170INFO:run['curl','-m','1','--connect-time','1','http://10.30.33.32']curl:(28)Connectiontimedoutafter1000milliseconds2018-02-2219:22:00,184INFO:commandreturned282018-02-2219:22:00,185INFO:waiting1.000000seconds,3retriesleft2018-02-2219:22:01,187INFO:run['curl','-m','1','--connect-time','1','http://10.30.33.32']curl:(28)Connectiontimedoutafter1005milliseconds2018-02-2219:22:02,209INFO:commandreturned282018-02-2219:22:02,210INFO:waiting1.200000seconds,2retriesleft2018-02-2219:22:03,414INFO:run['curl','-m','1','--connect-time','1','http://10.30.33.32']curl:(28)Connectiontimedoutafter1001milliseconds2018-02-2219:22:04,432INFO:commandreturned282018-02-2219:22:04,432INFO:waiting1.200000seconds,1retriesleft2018-02-2219:22:05,638INFO:run['curl','-m','1','--connect-time','1','http://10.30.33.32']curl:(28)Connectiontimedoutafter1006milliseconds2018-02-2219:22:06,662INFO:commandreturned28