Skip to content

Commit

Permalink
Switched from Thin to Puma webserver.
Browse files Browse the repository at this point in the history
Threads on Heroku have been limited to 1.

We need to test the rails app and make sure it is thread safe

See more info at https://devcenter.heroku.com/articles/deploying-rails-applications-with-the-puma-web-server
  • Loading branch information
muzfuz committed Feb 6, 2016
1 parent fb90acd commit 7cc491f
Show file tree
Hide file tree
Showing 5 changed files with 26 additions and 9 deletions.
3 changes: 2 additions & 1 deletion Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,8 @@ gem 'google-api-client', '~> 0.6.4'
gem 'devise', '~> 3.2.4' # For managing authentication
gem 'figaro', '~> 0.7.0' # Managing environment variables
gem 'github_api' #, '~> 0.11.1' # to pull in the curriculum files
gem 'thin', '~> 1.6.1' # to use the "thin" webserver instead of webrick
gem 'puma', '~> 2.16.0' # to use the "puma" webserver instead of webrick
gem 'rack-timeout', '~> 0.3.2'
gem 'redcarpet', '~> 3.0.0' # to render the curriculum's .md files as html
gem 'will_paginate', '~> 3.0.5' # to paginate student lists
gem 'protected_attributes', '~> 1.0.5'
Expand Down
13 changes: 5 additions & 8 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,6 @@ GEM
commonjs (0.2.7)
css_parser (1.3.7)
addressable
daemons (1.2.3)
database_cleaner (1.2.0)
debug_inspector (0.0.2)
descendants_tracker (0.0.4)
Expand All @@ -76,7 +75,6 @@ GEM
disqus (1.0.4)
json
erubis (2.7.0)
eventmachine (1.0.9.1)
execjs (2.6.0)
extlib (0.9.16)
factory_girl (4.3.0)
Expand Down Expand Up @@ -172,11 +170,13 @@ GEM
coderay (~> 1.1.0)
method_source (~> 0.8.1)
slop (~> 3.4)
puma (2.16.0)
quiet_assets (1.0.3)
railties (>= 3.1, < 5.0)
rack (1.5.5)
rack-test (0.6.3)
rack (>= 1.0)
rack-timeout (0.3.2)
rails (4.0.2)
actionmailer (= 4.0.2)
actionpack (= 4.0.2)
Expand Down Expand Up @@ -217,7 +217,7 @@ GEM
sass (~> 3.2.2)
sprockets (~> 2.8, < 3.0)
sprockets-rails (~> 2.0)
selenium-webdriver (2.50.0)
selenium-webdriver (2.51.0)
childprocess (~> 0.5)
multi_json (~> 1.0)
rubyzip (~> 1.0)
Expand All @@ -243,10 +243,6 @@ GEM
therubyracer (0.12.2)
libv8 (~> 3.16.14.0)
ref
thin (1.6.4)
daemons (~> 1.0, >= 1.0.9)
eventmachine (~> 1.0, >= 1.0.4)
rack (~> 1.0)
thor (0.19.1)
thread_safe (0.3.5)
tilt (1.4.1)
Expand Down Expand Up @@ -297,15 +293,16 @@ DEPENDENCIES
premailer-rails
protected_attributes (~> 1.0.5)
pry
puma (~> 2.16.0)
quiet_assets (~> 1.0.2)
rack-timeout (~> 0.3.2)
rails (= 4.0.2)
rails_12factor (~> 0.0.2)
redcarpet (~> 3.0.0)
rspec-rails (~> 2.14.1)
sass-rails (~> 4.0.1)
simple_form (~> 3.0.1)
therubyracer (~> 0.12.2)
thin (~> 1.6.1)
twitter-bootstrap-rails (= 2.2.6)
uglifier (>= 1.0.3)
will_paginate (~> 3.0.5)
1 change: 1 addition & 0 deletions Procfile
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
web: bundle exec puma -C config/puma.rb
3 changes: 3 additions & 0 deletions config/initializers/timeout.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
require 'rack-timeout'

Rack::Timeout.timeout = 20
15 changes: 15 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['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

0 comments on commit 7cc491f

Please sign in to comment.