Class: Tipi::Controller

Inherits:
Object
  • Object
show all
Defined in:
lib/tipi/controller/web_stock.rb,
lib/tipi/controller/web_polyphony.rb

Constant Summary collapse

WORKER_COUNT_RANGE =
(1..32).freeze

Instance Method Summary collapse

Constructor Details

#initialize(opts) ⇒ Controller

Returns a new instance of Controller.



268
269
270
271
272
# File 'lib/tipi/controller/web_stock.rb', line 268

def initialize(opts)
  @opts = opts
  @path = File.expand_path(@opts['path'])
  @service = prepare_service
end

Instance Method Details

#runObject



276
277
278
279
280
281
# File 'lib/tipi/controller/web_stock.rb', line 276

def run
  worker_count = (@opts['workers'] || 1).to_i.clamp(WORKER_COUNT_RANGE)
  return run_worker if worker_count == 1

  supervise_workers(worker_count)
end