mirror of
https://github.com/thegeeklab/retry.git
synced 2024-11-28 07:30:36 +00:00
add help and readme
This commit is contained in:
parent
4a9fc30085
commit
b02ed5a380
75
README.md
Normal file
75
README.md
Normal file
@ -0,0 +1,75 @@
|
|||||||
|
retryit - The command line retry tool
|
||||||
|
------------------------------------------
|
||||||
|
|
||||||
|
Retry any shell command with exponential backoff or constant delay.
|
||||||
|
|
||||||
|
### Instructions
|
||||||
|
|
||||||
|
Install:
|
||||||
|
|
||||||
|
`gem install retryit`
|
||||||
|
|
||||||
|
### Usage
|
||||||
|
|
||||||
|
Help:
|
||||||
|
|
||||||
|
`retry -?`
|
||||||
|
|
||||||
|
Usage: retry [options] -e execute command
|
||||||
|
-h, -?, --help
|
||||||
|
-t, --tries=# Set max retries: Default 10
|
||||||
|
-s, --sleep=secs Constant sleep amount (seconds)
|
||||||
|
-m, --min=secs Exponenetial Backoff: minimum sleep amount (seconds): Default 0.3
|
||||||
|
-x, --max=secs Exponenetial Backoff: maximum sleep amount (seconds): Default 60
|
||||||
|
|
||||||
|
### Examples
|
||||||
|
|
||||||
|
Test functionality:
|
||||||
|
|
||||||
|
`retry 'echo "y u no work"; false'`
|
||||||
|
|
||||||
|
y u no work
|
||||||
|
Before retry #1: sleeping 0.3 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #2: sleeping 0.6 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #3: sleeping 1.2 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #4: sleeping 2.4 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #5: sleeping 4.8 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #6: sleeping 9.6 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #7: sleeping 19.2 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #8: sleeping 38.4 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #9: sleeping 60.0 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #10: sleeping 60.0 seconds
|
||||||
|
y u no work
|
||||||
|
|
||||||
|
Limit retries:
|
||||||
|
|
||||||
|
`retry -t 4 -e 'echo "y u no work"; false'`
|
||||||
|
|
||||||
|
y u no work
|
||||||
|
Before retry #1: sleeping 0.3 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #2: sleeping 0.6 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #3: sleeping 1.2 seconds
|
||||||
|
y u no work
|
||||||
|
Before retry #4: sleeping 2.4 seconds
|
||||||
|
y u no work
|
||||||
|
|
||||||
|
Bad command:
|
||||||
|
|
||||||
|
`retry poop`
|
||||||
|
|
||||||
|
Command Failed: poop
|
||||||
|
|
||||||
|
### License
|
||||||
|
|
||||||
|
Apache 2.0 - go nuts
|
@ -18,6 +18,11 @@ class RetryIt
|
|||||||
optparser = OptionParser.new do |opts|
|
optparser = OptionParser.new do |opts|
|
||||||
opts.banner = "Usage: retry [options] -e execute command"
|
opts.banner = "Usage: retry [options] -e execute command"
|
||||||
|
|
||||||
|
opts.on("-h", "-?", "--help") do |v|
|
||||||
|
puts opts
|
||||||
|
exit
|
||||||
|
end
|
||||||
|
|
||||||
opts.on("-t#", "--tries=#", Integer, "Set max retries: Default 10") do |v|
|
opts.on("-t#", "--tries=#", Integer, "Set max retries: Default 10") do |v|
|
||||||
@max_tries = v
|
@max_tries = v
|
||||||
end
|
end
|
||||||
@ -26,11 +31,11 @@ class RetryIt
|
|||||||
@constant_sleep = v
|
@constant_sleep = v
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("--min=secs", Float, "Exponenetial Backoff: minimum sleep amount (seconds): Default 0.3") do |v|
|
opts.on("-m#", "--min=secs", Float, "Exponenetial Backoff: minimum sleep amount (seconds): Default 0.3") do |v|
|
||||||
@min_sleep = v
|
@min_sleep = v
|
||||||
end
|
end
|
||||||
|
|
||||||
opts.on("--max=secs", Float, "Exponenetial Backoff: maximum sleep amount (seconds): Default 60") do |v|
|
opts.on("-x#", "--max=secs", Float, "Exponenetial Backoff: maximum sleep amount (seconds): Default 60") do |v|
|
||||||
@max_sleep = v
|
@max_sleep = v
|
||||||
end
|
end
|
||||||
|
|
||||||
@ -49,6 +54,10 @@ class RetryIt
|
|||||||
|
|
||||||
def run(args)
|
def run(args)
|
||||||
|
|
||||||
|
if (["-h", "-?", "--help"].include? args[0])
|
||||||
|
load_options(args)
|
||||||
|
end
|
||||||
|
|
||||||
idx = args.find_index("-e")
|
idx = args.find_index("-e")
|
||||||
if !idx.nil?
|
if !idx.nil?
|
||||||
load_options(args[0...idx])
|
load_options(args[0...idx])
|
||||||
|
Loading…
Reference in New Issue
Block a user