class InciScore::Server

Constants

CPUs
DEFAULT_HOST
RACKUP_FILE

Public Class Methods

new(port: 9292, threads: "0: click to toggle source
# File lib/inci_score/server.rb, line 11
def initialize(port: 9292, threads: "0:#{CPUs*4}", workers: CPUs, preload: false, 
               config_klass: Puma::Configuration, launcher_klass: Puma::Launcher)
  @port = port
  @workers = workers
  @threads = threads.split(":")
  @preload = preload
  @config_klass = config_klass
  @launcher_klass = launcher_klass
end

Public Instance Methods

run() click to toggle source
# File lib/inci_score/server.rb, line 21
def run
  launcher.run
end

Private Instance Methods

config() click to toggle source
# File lib/inci_score/server.rb, line 29
        def config
  @config_klass.new do |c|
    c.rackup RACKUP_FILE
    c.bind "tcp://#{DEFAULT_HOST}:#{@port}"
    c.workers @workers if workers?
    c.threads(*@threads)
    c.preload_app! if @preload
  end
end
java?() click to toggle source
# File lib/inci_score/server.rb, line 43
        def java?
  RUBY_VERSION == "java"
end
launcher() click to toggle source
# File lib/inci_score/server.rb, line 25
        def launcher
  @launcher_klass.new(config)
end
windows?() click to toggle source
# File lib/inci_score/server.rb, line 47
        def windows?
  Gem.win_platform?
end
workers?() click to toggle source
# File lib/inci_score/server.rb, line 39
        def workers?
  @workers > 1 && !java? && !windows?
end