mirror of
https://github.com/neocities/neocities.git
synced 2025-08-04 00:31:59 +02:00
Better detection of # of cores available
This commit is contained in:
parent
54422802e5
commit
7adb8b0c9b
3 changed files with 6 additions and 19 deletions
|
@ -1,28 +1,12 @@
|
|||
def processor_count
|
||||
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
|
||||
require 'facter'
|
||||
|
||||
threads 1, 1
|
||||
environment 'production'
|
||||
daemonize
|
||||
#daemonize
|
||||
pidfile '/var/run/neocities/neocities.pid'
|
||||
stdout_redirect '/var/log/neocities/neocities.log', '/var/log/neocities/neocities-errors.log', true
|
||||
quiet
|
||||
workers processor_count
|
||||
workers Facter.value('processors')['count']
|
||||
worker_timeout 600
|
||||
preload_app!
|
||||
on_worker_boot { DB.disconnect }
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue