Sha256: 846e0f6d97b7e0b7c731e9b60ae1f40ae33bf2593574774dd9295ba9fbcb89bd

Contents?: true

Size: 673 Bytes

Versions: 4

Compression:

Stored size: 673 Bytes

Contents

class Chef
  class Recipe
    def get_resque_worker_count      
      # $ sudo cat /proc/meminfo
      # MemTotal:        1759228 kB
      # ...
      mem_total_kb = `awk '/MemTotal/{print $2}' /proc/meminfo`.strip.to_i
      mem_total_mb = mem_total_kb / 1024

      # Want no more than ((total memory - 300) / est process size) workers + jobs to run
      # in other words, if all workers on the instance are running jobs, there should
      #   be memory left over
      result = (mem_total_mb - node[:worker_memory].to_i) / node[:worker_memory].to_i
      result /= 2 if node[:instance_role] == 'solo' || node[:instance_role] == 'eylocal'
      result
    end
  end
end

Version data entries

4 entries across 4 versions & 1 rubygems

Version Path
eycloud-recipe-resque-1.0.3 libraries/get_resque_worker_count.rb
eycloud-recipe-resque-1.0.2 libraries/get_resque_worker_count.rb
eycloud-recipe-resque-1.0.1 libraries/get_resque_worker_count.rb
eycloud-recipe-resque-1.0 libraries/get_resque_worker_count.rb