Better detection of # of cores available

This commit is contained in:
Kyle Drake 2017-03-22 17:47:07 -07:00
parent 54422802e5
commit 7adb8b0c9b
3 changed files with 6 additions and 19 deletions

View file

@ -52,6 +52,7 @@ gem 'pg'
gem 'sequel_pg', require: nil gem 'sequel_pg', require: nil
gem 'hiredis' gem 'hiredis'
gem 'activesupport' gem 'activesupport'
gem 'facter'
group :development, :test do group :development, :test do
gem 'pry' gem 'pry'

View file

@ -65,6 +65,7 @@ GEM
erubis (2.7.0) erubis (2.7.0)
exifr (1.2.5) exifr (1.2.5)
fabrication (2.15.0) fabrication (2.15.0)
facter (2.4.6)
faker (1.6.3) faker (1.6.3)
i18n (~> 0.5) i18n (~> 0.5)
faraday (0.9.2) faraday (0.9.2)
@ -298,6 +299,7 @@ DEPENDENCIES
dav4rack! dav4rack!
erubis erubis
fabrication fabrication
facter
faker faker
feedjira feedjira
filesize filesize

View file

@ -1,28 +1,12 @@
def processor_count require 'facter'
case RbConfig::CONFIG['host_os']
when /darwin9/
`hwprefs cpu_count`.to_i
when /darwin/
((`which hwprefs` != '') ? `hwprefs thread_count` : `sysctl -n hw.ncpu`).to_i
when /linux/
`cat /proc/cpuinfo | grep processor | wc -l`.to_i
when /freebsd/
`sysctl -n hw.ncpu`.to_i
when /mswin|mingw/
require 'win32ole'
wmi = WIN32OLE.connect("winmgmts://")
cpu = wmi.ExecQuery("select NumberOfCores from Win32_Processor") # TODO count hyper-threaded in this
cpu.to_enum.first.NumberOfCores
end
end
threads 1, 1 threads 1, 1
environment 'production' environment 'production'
daemonize #daemonize
pidfile '/var/run/neocities/neocities.pid' pidfile '/var/run/neocities/neocities.pid'
stdout_redirect '/var/log/neocities/neocities.log', '/var/log/neocities/neocities-errors.log', true stdout_redirect '/var/log/neocities/neocities.log', '/var/log/neocities/neocities-errors.log', true
quiet quiet
workers processor_count workers Facter.value('processors')['count']
worker_timeout 600 worker_timeout 600
preload_app! preload_app!
on_worker_boot { DB.disconnect } on_worker_boot { DB.disconnect }