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



7
8
9
10
11
12
13
14
# 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