Class: Switchman::Environment

Inherits:
Object
  • Object
show all
Defined in:
lib/switchman/environment.rb

Class Method Summary collapse

Class Method Details

.cpu_count(nproc_bin = "nproc") ⇒ Object



6
7
8
9
10
11
12
13
14
15
# File 'lib/switchman/environment.rb', line 6

def self.cpu_count(nproc_bin = "nproc")
  if Etc.respond_to?(:nprocessors)
    return Etc.nprocessors
  end

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