Sha256: c45c5fc22e5b6f4ecd193112c81185bd5562fdbd3b9ddd774665418c2337b9d6

Contents?: true

Size: 949 Bytes

Versions: 1

Compression:

Stored size: 949 Bytes

Contents

require 'get_process_mem'

module PumaAutoTune; end

require 'puma_auto_tune/version'
require 'puma_auto_tune/master'
require 'puma_auto_tune/worker'
require 'puma_auto_tune/memory'


module PumaAutoTune
  INFINITY    = 1/0.0
  RESOURCES = { ram: PumaAutoTune::Memory.new }

  extend self

  attr_accessor :ram, :max_workers, :frequency, :reap_duration
  self.ram           = 512  # mb
  self.max_workers   = INFINITY
  self.frequency     = 10 # seconds
  self.reap_duration = 90 # seconds


  def self.config
    yield self
    self
  end

  def self.hooks(name = nil, resource = nil, &block)
    @hooks       ||= {}
    return @hooks if name.nil?
    resource     ||= RESOURCES[name] || raise("no default resource specified for #{name.inspect}")
    @hooks[name] ||= Hook.new(resource)
    block.call(@hooks[name]) if block
    @hooks[name]
  end

  def start
    hooks.map {|name, hook| hook.auto_cycle}
  end
end


require 'puma_auto_tune/hook'

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
puma_auto_tune-0.0.1 lib/puma_auto_tune.rb