summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authormo khan <mo@mokhan.ca>2014-11-14 20:16:08 -0700
committermo khan <mo@mokhan.ca>2014-11-14 20:16:08 -0700
commitd719699adfe64d7c22885e7a2d30c31961471ae9 (patch)
tree94fd17d3f20f495d508489c611e4ab00ffa3c66a
parenta28ebe9cfba7a82403ee54eab786c202a0656493 (diff)
add config for puma.
-rw-r--r--Procfile2
-rw-r--r--config/puma.rb17
2 files changed, 18 insertions, 1 deletions
diff --git a/Procfile b/Procfile
index 485e29c..c2c566e 100644
--- a/Procfile
+++ b/Procfile
@@ -1 +1 @@
-web: bundle exec rails s -p $PORT
+web: bundle exec puma -C config/puma.rb
diff --git a/config/puma.rb b/config/puma.rb
new file mode 100644
index 0000000..95b40e1
--- /dev/null
+++ b/config/puma.rb
@@ -0,0 +1,17 @@
+workers Integer(ENV['PUMA_WORKERS'] || 3)
+threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16)
+
+preload_app!
+
+rackup DefaultRackup
+port ENV['PORT'] || 3000
+environment ENV['RACK_ENV'] || 'development'
+
+on_worker_boot do
+ # worker specific setup
+ ActiveSupport.on_load(:active_record) do
+ config = ActiveRecord::Base.configurations[Rails.env] || Rails.application.config.database_configuration[Rails.env]
+ config['pool'] = ENV['MAX_THREADS'] || 16
+ ActiveRecord::Base.establish_connection(config)
+ end
+end