0
+def create_spec_list(options)
0
+ result.concat("-I#{FUZED_ROOT + "/rlibs "}")
0
+ raise "You must specify a fuzed file to join the fuzed cluster!" unless options[:fuzedfile]
0
+ result.concat(options[:fuzedfile] + " ")
0
+ result.concat(%{--tags="#{options[:tags]}" }) if options[:tags]
0
+ roles << "production" if options[:production]
0
+ roles << options[:roles] if options[:roles]
0
+ result.concat(%{--roles="#{roles.join(",")}"}) unless roles.empty?
0
+ result.concat(%{ -- }) # Separates required arguments from optionals
0
+ spec_list = if options[:spec]
0
+ specs = options[:spec].split(/\|\|/)
0
+ specs.map {|x| result + x}
0
+ spec_list.map {|x| x.gsub(%r|\\|,'\\\\\\').gsub(%r|([\"\'])|, '\\\\\1')} # Make sure to escape things properly.
0
+options = {:fuzedfile => rel("rlibs/rails_node.rb")}
0
+OptionParser.new do |opts|
0
+ opts.banner = "Usage: fuzed command [options]"
0
+ opts.on("-z HOSTNAME", "--magic HOSTNAME", "Set smart details based off of a hostname") do |n|
0
+ options[:master_name] = "master@#{n}"
0
+ opts.on("-n NAME", "--name NAME", "Node name") do |n|
0
+ opts.on("-m NAME", "--master NAME", "Master node name") do |n|
0
+ options[:master_name] = n
0
+ opts.on("--rails-root RAILS_ROOT", "Location of the Rails root") do |n|
0
+ options[:spec] = "--rails-root=#{n}"
0
+ opts.on("-c NUMNODES", "--clone NUMTIMES", "Number of clones of your spec to make") do |n|
0
+ options[:num_nodes] = n
0
+ opts.on("-t", "--tags TAGSTRING", "Comma-separated list of tags to apply to any nodes started") do |n|
0
+ opts.on("-d", "--detached", "Run as a daemon") do
0
+ options[:detached] = true
0
+ opts.on("-p", "--production", "Classify these nodes as production") do
0
+ options[:production] = true
0
+ opts.on("-r", "--roles ROLES", "Extra roles (use -p for production role)") do |v|
0
+ opts.on("-i", "--inet", "Load code over internet via master code server") do
0
+ opts.on("-h", "--heartbeat", "Start with a heartbeat.") do
0
+ $stderr.puts "WARNING! Heartbeats not supported with this build!"
0
+detached = options[:detached] ? '-detached' : ''
0
+master = options[:master_name] || DEFAULT_MASTER_NODE
0
+nodename = options[:name] || DEFAULT_NODE_NAME
0
+ abort "Please specify fully qualified master node name e.g. -m master@fuzed.tools.powerset.com"
0
+spec = %{[} + create_spec_list(options).map {|x| %{"#{x}"}}.join(",") + %{]}
0
+num_nodes = options[:num_nodes] || 1
0
+ # Ruby has an awesome bug that makes me have to shell out to it, I'm not insane, I swear
0
+ ip = `ruby -e "require 'resolv'; puts Resolv.getaddress('#{master.split('@').last}') rescue ''"`.chomp
0
+ ip = `ruby -e "require 'resolv'; puts Resolv.getaddress('#{master.split('@').last.split('.').first}') rescue ''"`.chomp if ip == ''
0
+ abort("Could not resolve #{master.split('@').last} to an IP address") unless ip
0
+ " -loader inet -hosts '#{ip}'"
0
+cmd = %Q{erl -boot start_sasl \
0
+ -setcookie #{cookie_hash(master)} \
0
+ -fuzed_node master "'#{master}'" \
0
+ -fuzed_node spec '#{spec}' \
0
+ -fuzed_node num_nodes #{num_nodes} \
0
+ -config '#{FUZED_ROOT}/conf/fuzed_base' \
0
+ -run fuzed_node start}.squeeze(' ')
Comments
No one has commented yet.