Sha256: b3da07b779eb5354a17a84d5350ee607d05b6d77c08be0cc2d0028844d8b6e9a

Contents?: true

Size: 318 Bytes

Versions: 42

Compression:

Stored size: 318 Bytes

Contents

# frozen_string_literal: true

require 'etc'

module Switchman
  class Environment
    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
  end
end

Version data entries

42 entries across 42 versions & 1 rubygems

Version Path
switchman-3.0.1 lib/switchman/environment.rb
switchman-3.0.0 lib/switchman/environment.rb