From 6559f9b1291debf8d42d1e1d7149881b637529b0 Mon Sep 17 00:00:00 2001 From: Kyle Drake Date: Tue, 20 Oct 2015 11:24:00 -0700 Subject: [PATCH] config for puma --- environment.rb | 2 ++ puma_config.rb | 28 ++++++++++++++++++++++++++++ 2 files changed, 30 insertions(+) create mode 100644 puma_config.rb diff --git a/environment.rb b/environment.rb index 6d9911a9..e47d2490 100644 --- a/environment.rb +++ b/environment.rb @@ -11,6 +11,8 @@ require 'logger' Bundler.require Bundler.require :development if ENV['RACK_ENV'] == 'development' +require 'tilt/erubis' + Dir['./ext/**/*.rb'].each {|f| require f} # :nocov: diff --git a/puma_config.rb b/puma_config.rb new file mode 100644 index 00000000..5fb01d68 --- /dev/null +++ b/puma_config.rb @@ -0,0 +1,28 @@ +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 + +environment 'production' +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 +worker_timeout 600 +preload_app! +on_worker_boot { DB.disconnect } +bind 'unix:/var/run/neocities/neocities.sock?backlog=2048'