From 9aada1786c29fd15c4fe2c20ed6f97b66d2d7d40 Mon Sep 17 00:00:00 2001 From: Jason Yeo Date: Sat, 6 Dec 2014 19:02:28 +0800 Subject: [PATCH 1/4] Check-in puma config --- config/{puma.rb.sample => puma.rb} | 0 1 file changed, 0 insertions(+), 0 deletions(-) rename config/{puma.rb.sample => puma.rb} (100%) diff --git a/config/puma.rb.sample b/config/puma.rb similarity index 100% rename from config/puma.rb.sample rename to config/puma.rb From 5d876bf174c6d8c406d14fcaa63a9686b92a82d8 Mon Sep 17 00:00:00 2001 From: Jason Yeo Date: Sat, 6 Dec 2014 19:03:21 +0800 Subject: [PATCH 2/4] Update puma config with config from server --- config/puma.rb | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/config/puma.rb b/config/puma.rb index bb2873488..d7dbd0a59 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -14,11 +14,11 @@ pidfile 'tmp/pids/puma.pid' state_path 'tmp/pids/puma.state' -# stdout_redirect 'log/puma.log', 'log/puma_err.log' +stdout_redirect 'log/puma.log', 'log/puma_err.log' # quiet -threads 0, 30 -bind 'unix://tmp/sockets/puma.sock' +threads 10, 20 +bind 'unix:///var/www/coursemology/tmp/sockets/puma.sock' # ssl_bind '127.0.0.1', '9292', { key: path_to_key, cert: path_to_cert } @@ -31,8 +31,7 @@ # === Cluster mode === -# workers 2 - +workers 2 # on_worker_boot do # puts 'On worker boot...' # end @@ -40,3 +39,5 @@ # === Puma control rack application === activate_control_app 'unix://tmp/sockets/pumactl.sock' + +preload_app! From b1f7447ffa7af98241c3650affbaec0aa46ee7ef Mon Sep 17 00:00:00 2001 From: Jason Yeo Date: Tue, 9 Dec 2014 11:17:16 +0800 Subject: [PATCH 3/4] Grab min and max threads from env for easy tuning. Don't daemonize. Don't create pids. Create sockets in /tmp --- config/puma.rb | 10 +++------- 1 file changed, 3 insertions(+), 7 deletions(-) diff --git a/config/puma.rb b/config/puma.rb index d7dbd0a59..fede0270d 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -9,16 +9,12 @@ # end environment 'production' -daemonize true - -pidfile 'tmp/pids/puma.pid' -state_path 'tmp/pids/puma.state' stdout_redirect 'log/puma.log', 'log/puma_err.log' # quiet -threads 10, 20 -bind 'unix:///var/www/coursemology/tmp/sockets/puma.sock' +threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 20) +bind 'unix:///tmp/coursemology_puma.sock' # ssl_bind '127.0.0.1', '9292', { key: path_to_key, cert: path_to_cert } @@ -38,6 +34,6 @@ # === Puma control rack application === -activate_control_app 'unix://tmp/sockets/pumactl.sock' +activate_control_app 'unix:///tmp/coursemology_pumactl.sock' preload_app! From b3e0aa4d28e977b9f025f6ea26a79662a775bee2 Mon Sep 17 00:00:00 2001 From: Jason Yeo Date: Tue, 9 Dec 2014 11:30:20 +0800 Subject: [PATCH 4/4] Probably shouldn't use so many threads for default max threads --- config/puma.rb | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/config/puma.rb b/config/puma.rb index fede0270d..f3e8941f6 100644 --- a/config/puma.rb +++ b/config/puma.rb @@ -13,7 +13,7 @@ stdout_redirect 'log/puma.log', 'log/puma_err.log' # quiet -threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 20) +threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 10) bind 'unix:///tmp/coursemology_puma.sock' # ssl_bind '127.0.0.1', '9292', { key: path_to_key, cert: path_to_cert }