Sha256: 2e4eba9c16646797d01ff10d39cd36bbb9225f2904b807e281971fbea62f306e

Contents?: true

Size: 352 Bytes

Versions: 22

Compression:

Stored size: 352 Bytes

Contents

# frozen_string_literal: true

require 'etc'

module Switchman
  class Environment

    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

  end
end

Version data entries

22 entries across 22 versions & 1 rubygems

Version Path
switchman-2.2.3 lib/switchman/environment.rb
switchman-2.2.2 lib/switchman/environment.rb
switchman-2.2.1 lib/switchman/environment.rb
switchman-2.2.0 lib/switchman/environment.rb
switchman-2.1.6 lib/switchman/environment.rb
switchman-2.1.5 lib/switchman/environment.rb
switchman-2.1.4 lib/switchman/environment.rb
switchman-2.1.3 lib/switchman/environment.rb
switchman-2.1.2 lib/switchman/environment.rb
switchman-2.1.1 lib/switchman/environment.rb
switchman-2.1.0 lib/switchman/environment.rb
switchman-2.0.13 lib/switchman/environment.rb
switchman-2.0.12 lib/switchman/environment.rb
switchman-2.0.11 lib/switchman/environment.rb
switchman-2.0.10 lib/switchman/environment.rb
switchman-2.0.9 lib/switchman/environment.rb
switchman-2.0.8 lib/switchman/environment.rb
switchman-2.0.7 lib/switchman/environment.rb
switchman-2.0.6 lib/switchman/environment.rb
switchman-2.0.5 lib/switchman/environment.rb