Class: Up::Ruby::Cluster
Instance Method Summary collapse
-
#initialize(app:, host: 'localhost', port: 3000, scheme: 'http', ca_file: nil, cert_file: nil, key_file: nil, logger: Logger.new(STDERR), workers: nil) ⇒ Cluster
constructor
A new instance of Cluster.
- #listen ⇒ Object
- #stop ⇒ Object
Methods inherited from Server
Constructor Details
#initialize(app:, host: 'localhost', port: 3000, scheme: 'http', ca_file: nil, cert_file: nil, key_file: nil, logger: Logger.new(STDERR), workers: nil) ⇒ Cluster
Returns a new instance of Cluster.
10 11 12 13 14 15 |
# File 'lib/up/ruby/cluster.rb', line 10 def initialize(app:, host: 'localhost', port: 3000, scheme: 'http', ca_file: nil, cert_file: nil, key_file: nil, logger: Logger.new(STDERR), workers: nil) super(app: app, host: host, port: port) @secret = Random.uuid @workers = workers || Etc.nprocessors @members = [] end |
Instance Method Details
#listen ⇒ Object
17 18 19 20 21 22 23 24 25 26 27 28 29 30 |
# File 'lib/up/ruby/cluster.rb', line 17 def listen raise "already running" unless @members.empty? ::Up.instance_variable_set(:@instance, self) @workers.times do @members << fork do @member_id = @members.size + 1 super end end unless @member_id install_signal_handlers Process.waitall end end |
#stop ⇒ Object
32 33 34 35 36 |
# File 'lib/up/ruby/cluster.rb', line 32 def stop if Up::CLI::stoppable? kill_members end end |