class Switchman::Environment

Public Class Methods

cpu_count(nproc_bin = 'nproc') click to toggle source
# File lib/switchman/environment.rb, line 7
def self.cpu_count(nproc_bin = 'nproc')
  return Etc.nprocessors if Etc.respond_to?(:nprocessors)

  `#{nproc_bin}`.to_i
rescue Errno::ENOENT
  # an environment where nproc` isnt available
  0
end