From 8bdc32ec307847867c65eae632e6525141349b60 Mon Sep 17 00:00:00 2001 From: manson Date: Fri, 29 Aug 2014 15:40:58 +0800 Subject: [PATCH] change unicorn num of workers to num of cpu cores --- config/unicorn.rb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/config/unicorn.rb b/config/unicorn.rb index a3daec0..4e5c8d1 100644 --- a/config/unicorn.rb +++ b/config/unicorn.rb @@ -4,7 +4,10 @@ rails_root = `pwd`.gsub("\n", "") rails_env = ENV['RAILS_ENV'] || 'production' -worker_processes (rails_env == 'production' ? 4 : 2) + +cpu_cores = %x(cat /proc/cpuinfo | grep processor | wc -l).sub("\n",'').to_i rescue 2 + +worker_processes (rails_env == 'production' ? cpu_cores : 1) # preload_app true