diff --git a/Gemfile b/Gemfile index 194234af..9351d6c9 100644 --- a/Gemfile +++ b/Gemfile @@ -1,6 +1,9 @@ source 'https://rubygems.org' gem 'rails', '4.2.5' +gem 'puma', '~> 3.6.0' +gem 'puma-heroku' +gem 'rack-timeout' # Storage gem 'aws-sdk', '~> 1.50' diff --git a/Gemfile.lock b/Gemfile.lock index d9d8eb26..84085bf6 100644 --- a/Gemfile.lock +++ b/Gemfile.lock @@ -201,9 +201,13 @@ GEM coderay (~> 1.1.0) method_source (~> 0.8.1) slop (~> 3.4) + puma (3.6.0) + puma-heroku (1.0.0) + puma (~> 3.0) rack (1.6.4) rack-test (0.6.3) rack (>= 1.0) + rack-timeout (0.4.2) rails (4.2.5) actionmailer (= 4.2.5) actionpack (= 4.2.5) @@ -361,6 +365,9 @@ DEPENDENCIES paperclip (~> 4.2.0) pg pry + puma (~> 3.6.0) + puma-heroku + rack-timeout rails (= 4.2.5) rails-jquery-autocomplete rails-perftest diff --git a/Procfile b/Procfile new file mode 100644 index 00000000..c2c566e8 --- /dev/null +++ b/Procfile @@ -0,0 +1 @@ +web: bundle exec puma -C config/puma.rb diff --git a/config/database.yml b/config/database.yml index 1e515893..1e0ae3ba 100644 --- a/config/database.yml +++ b/config/database.yml @@ -22,6 +22,7 @@ test: &test cucumber: <<: *test - + production: url: <%= ENV['DATABASE_URL'] %> + pool: <%= ENV['RAILS_MAX_THREADS'] || 5 %> diff --git a/config/initializers/rack_timeout.rb b/config/initializers/rack_timeout.rb new file mode 100644 index 00000000..96f24619 --- /dev/null +++ b/config/initializers/rack_timeout.rb @@ -0,0 +1 @@ +Rack::Timeout.timeout = 20 # seconds diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 00000000..bbe4a6f7 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,17 @@ +require 'puma/plugin/heroku' + +workers Integer(ENV['WEB_CONCURRENCY'] || 2) +threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5) +threads threads_count, threads_count + +preload_app! + +rackup DefaultRackup +port ENV['PORT'] || 3000 +environment ENV['RACK_ENV'] || 'development' + +on_worker_boot do + # Worker specific setup for Rails 4.1+ + # See: https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server#on-worker-boot + ActiveRecord::Base.establish_connection +end