Skip to content

Commit

Permalink
Replace unicorn with puma
Browse files Browse the repository at this point in the history
  • Loading branch information
mjankowski committed Oct 2, 2018
1 parent d44445d commit d38c9d8
Show file tree
Hide file tree
Showing 5 changed files with 52 additions and 39 deletions.
4 changes: 2 additions & 2 deletions Gemfile
Original file line number Diff line number Diff line change
Expand Up @@ -20,15 +20,15 @@ gem "omniauth"
gem "omniauth-github-team-member"
gem "omniauth-oauth2", "~> 1.3.1"
gem "pg"
gem "puma"
gem "rack-timeout"
gem "rake", "~> 11"
gem "rails", "~> 4.2"
gem "rake", "~> 11"
gem "recipient_interceptor"
gem "sass-rails"
gem "time_for_a_boolean"
gem "title"
gem "uglifier"
gem "unicorn"

group :development do
gem "bundler-audit"
Expand Down
8 changes: 2 additions & 6 deletions Gemfile.lock
Original file line number Diff line number Diff line change
Expand Up @@ -167,7 +167,6 @@ GEM
kaminari (0.17.0)
actionpack (>= 3.0.0)
activesupport (>= 3.0.0)
kgio (2.11.2)
launchy (2.4.3)
addressable (~> 2.3)
loofah (2.2.2)
Expand Down Expand Up @@ -218,6 +217,7 @@ GEM
pry-rails (0.3.4)
pry (>= 0.9.10)
public_suffix (3.0.3)
puma (3.12.0)
rack (1.6.10)
rack-test (0.6.3)
rack (>= 1.0)
Expand Down Expand Up @@ -252,7 +252,6 @@ GEM
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
rainbow (3.0.0)
raindrops (0.19.0)
rake (11.3.0)
ransack (1.7.0)
actionpack (>= 3.0)
Expand Down Expand Up @@ -331,9 +330,6 @@ GEM
execjs (>= 0.3.0)
json (>= 1.8.0)
unicode-display_width (1.4.0)
unicorn (5.4.1)
kgio (~> 2.6)
raindrops (~> 0.7)
webmock (3.4.2)
addressable (>= 2.3.6)
crack (>= 0.3.2)
Expand Down Expand Up @@ -373,6 +369,7 @@ DEPENDENCIES
omniauth-oauth2 (~> 1.3.1)
pg
pry-rails
puma
rack-timeout
rails (~> 4.2)
rails_12factor
Expand All @@ -386,7 +383,6 @@ DEPENDENCIES
timecop
title
uglifier
unicorn
webmock

RUBY VERSION
Expand Down
2 changes: 1 addition & 1 deletion Procfile
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
web: bundle exec puma -C ./config/puma.rb
worker: bundle exec rake jobs:work
47 changes: 47 additions & 0 deletions config/puma.rb
Original file line number Diff line number Diff line change
@@ -0,0 +1,47 @@
# Puma can serve each request in a thread from an internal thread pool.
# The `threads` method setting takes two numbers a minimum and maximum.
# Any libraries that use thread pools should be configured to match
# the maximum value specified for Puma. Default is set to 5 threads for minimum
# and maximum, this matches the default thread size of Active Record.
#
threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count

# Specifies the `port` that Puma will listen on to receive requests, default is 3000.
#
port ENV.fetch("PORT") { 3000 }

# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }

# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked webserver processes. If using threads and workers together
# the concurrency of the application would be max `threads` * `workers`.
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch("WEB_CONCURRENCY") { 2 }

# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory. If you use this option
# you need to make sure to reconnect any threads in the `on_worker_boot`
# block.
#
preload_app!

# The code in the `on_worker_boot` will be called if you are using
# clustered mode by specifying a number of `workers`. After each worker
# process is booted this block will be run, if you are using `preload_app!`
# option you will want to use this block to reconnect to any threads
# or connections that may have been created at application boot, Ruby
# cannot share connections between processes.
#
on_worker_boot do
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
end

# Allow puma to be restarted by `rails restart` command.
plugin :tmp_restart
30 changes: 0 additions & 30 deletions config/unicorn.rb

This file was deleted.

0 comments on commit d38c9d8

Please sign in to comment.