Class: Up::Node::Cluster
Instance Method Summary collapse
-
#initialize(app:, host: 'localhost', port: 3000, scheme: 'http', ca_file: nil, cert_file: nil, key_file: nil, workers: nil) ⇒ Cluster
constructor
A new instance of Cluster.
- #listen ⇒ Object
- #stop ⇒ Object
Constructor Details
#initialize(app:, host: 'localhost', port: 3000, scheme: 'http', ca_file: nil, cert_file: nil, key_file: nil, workers: nil) ⇒ Cluster
Returns a new instance of Cluster.
12 13 14 15 16 |
# File 'lib/up/node/cluster.rb', line 12 def initialize(app:, host: 'localhost', port: 3000, scheme: 'http', ca_file: nil, cert_file: nil, key_file: nil, workers: nil) super(app: app, host: host, port: port, scheme: scheme, ca_file: ca_file, cert_file: cert_file, key_file: key_file) @workers = workers || `num_workers` @members = [] end |
Instance Method Details
#listen ⇒ Object
18 19 20 21 22 23 24 25 26 27 28 29 |
# File 'lib/up/node/cluster.rb', line 18 def listen raise "already running" unless @members.empty? %x{ if (cluster.isPrimary) { for (let i = 0; i < #@workers; i++) { #@members.push(cluster.fork()); } } else { #{super} } } end |
#stop ⇒ Object
31 32 33 34 35 36 |
# File 'lib/up/node/cluster.rb', line 31 def stop if Up::CLI::stoppable? @members.each { |m| `m.kill()` } @members.clear end end |