diff --git a/mssh/bin/mcmd b/mssh/bin/mcmd index b910eb7..d0a8c30 100755 --- a/mssh/bin/mcmd +++ b/mssh/bin/mcmd @@ -5,6 +5,8 @@ require 'pp' $LOAD_PATH.unshift(File.expand_path(File.dirname(__FILE__) + "/../lib")) require 'mcmd' +require 'rubygems' +require 'rangeclient' require 'optparse' options = { :maxflight => 200, @@ -14,28 +16,28 @@ options = { optparse = OptionParser.new do |opts| opts.on('-r', '--range RANGE', 'currently takes a CSV list') do |arg| - options[:range] = arg + options[:range] = arg end opts.on('-m', '--maxflight 50', 'How many subprocesses? 50 by default') do |arg| - options[:maxflight] = arg + options[:maxflight] = arg end opts.on('-t', '--timeout 60', 'How many seconds may each individual process take? 0 for no timeout') do |arg| - options[:timeout] = arg + options[:timeout] = arg end opts.on('-g', '--global_timeout 600', 'How many seconds for the whole shebang 0 for no timeout') do |arg| - options[:global_timeout] = arg + options[:global_timeout] = arg end opts.on('--noshell', "Don't invoke a shell. Args will be passed to exec verbatim ") do |arg| - options[:noshell] = arg + options[:noshell] = arg end opts.on('-c', '--collapse', "Collapse similar output ") do |arg| - options[:collapse] = arg + options[:collapse] = arg end opts.on('-v', '--verbose', "Verbose output") do |arg| - options[:verbose] = arg + options[:verbose] = arg end opts.on('-d', '--debug', "Debug output") do |arg| - options[:debug] = arg + options[:debug] = arg end # option to merge stdin/stdout into one buf? how should this work? # option to ignore as-we-go yield output - this is off by default now except for success/fail @@ -47,7 +49,9 @@ raise "Error, need command to run" if ARGV.size.zero? m = MultipleCmd.new -targets = options[:range].split "," +range = Range::Client.new +targets = [] +targets.push(*range.expand(options[:range])) m.commands = targets.map { |t| ["/bin/sh", "-c"].push ARGV.map { |arg| arg.gsub('HOSTNAME', t)}.join " " } command_to_target = Hash.new diff --git a/mssh/mssh.gemspec b/mssh/mssh.gemspec index 4cee909..1b6804e 100644 --- a/mssh/mssh.gemspec +++ b/mssh/mssh.gemspec @@ -1,7 +1,7 @@ # -*- encoding: utf-8 -*- Gem::Specification.new do |s| s.name = "mssh" - s.version = "0.0.9" + s.version = "0.0.10" s.platform = Gem::Platform::RUBY s.authors = ["Evan Miller"] s.email = ["github@squareup.com"] @@ -13,6 +13,7 @@ Gem::Specification.new do |s| s.add_dependency "json" s.add_dependency "io-poll" + s.add_dependency "rangeclient" s.default_executable = %q{mssh} s.executables = %W{ mssh mcmd }