public
Description: An introduction to distributed computation with load balancers, proxies, and locality strategies.
Homepage:
Clone URL: git://github.com/nkallen/gogaruco.git
gogaruco / joke_cluster.rb
100755 20 lines (16 sloc) 0.44 kb
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
#!/usr/bin/env ruby
 
require 'optparse'
 
begin
  $options = {
    :count => 10,
    :base_port => 10000
  }
  OptionParser.new do |opts|
    opts.on('-n', "--number COUNT", Integer) { |count| $options[:count] = count }
    opts.on('-p', "--port PORT", Integer) { |count| $options[:port] = port }
  end.parse!
end
 
$options[:count].times do |count|
  port = $options[:base_port] + count + 1
  fork { exec("./joke_server.rb -p#{port}") }
end