lib/gizzmo.rb in gizzmo-0.6.0 vs lib/gizzmo.rb in gizzmo-0.7.0

- old
+ new

@@ -81,11 +81,11 @@ separators(opts, DOC_STRINGS["report"]) end, 'rebalance' => OptionParser.new do |opts| opts.banner = "Usage: #{zero} rebalance" separators(opts, DOC_STRINGS["rebalance"]) - + opts.on("-h", "--hosts=list") do |h| subcommand_options.hosts = h end end, 'repair' => OptionParser.new do |opts| @@ -228,10 +228,14 @@ opts.on("-P", "--port=PORT", "PORT of remote thrift service") do |port| global_options.port = port end + opts.on("-r", "--retry=TIMES", "TIMES to retry the command") do |r| + global_options.retry = r + end + opts.on("--subtree", "Render in subtree mode") do global_options.render << "subtree" end opts.on("--info", "Render in info mode") do @@ -301,11 +305,23 @@ while !$stdin.tty? && line = STDIN.gets argv << line.strip end +tries_left = global_options.retry.to_i + 1 begin - Gizzard::Command.run(subcommand_name, global_options, argv, subcommand_options, log) + while (tries_left -= 1) >= 0 + begin + Gizzard::Command.run(subcommand_name, global_options, argv, subcommand_options, log) + break + rescue + if tries_left > 0 + STDERR.puts "Retrying..." + else + raise + end + end + end rescue HelpNeededError => e if e.class.name != e.message STDERR.puts("=" * 80) STDERR.puts e.message STDERR.puts("=" * 80) \ No newline at end of file