Sha256: 2151a007e66771ce1509e9e85f4fce11e79b389b201b0bfceb993736b044ec27

Contents?: true

Size: 888 Bytes

Versions: 1

Compression:

Stored size: 888 Bytes

Contents

require 'pp'
require 'rbconfig'
require 'optparse'


# run a new ruby-interpreter in a separate process and return it's pid 
def ruby(*x)
  rb="ruby"
  $pcount||=0
  $pcount+=1
  pcount=$pcount
  Process.fork {
    fn="log#{pcount}.txt"
    puts fn
    puts `#{rb} #{x.join(" ")} >#{fn}` 
  }
end

# default number of process is 4
options={:count=>4}
opts=OptionParser.new do |opts|
  opts.banner = "Usage: nettest [options]"
 
  opts.separator ""
  opts.separator "Specific options:"
 
  opts.on("-d", "--enable-debug",
         "enable debugging") do 
   options[:debug]=true
  end
  opts.on("--count PROESS_COUNT") do |count|
    options[:count]=count.to_i
  end
  if block_given?
   yield opts
  end

end

opts.parse!
pp options

options[:count].times{|c|
  puts "starting Process #{c}"
  ruby("main.rb","--http-port",2000+c)
}

puts "Waiting for processes to finish..."

Process.wait

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
appswarm-0.0.1 nettest.rb