Replace Unicorn with Puma

This commit is contained in:
Hakan Ensari 2018-07-20 21:02:46 +01:00
parent a96e56808e
commit 11c2d760bc
7 changed files with 18 additions and 22 deletions

View File

@ -6,4 +6,4 @@ ADD Gemfile /app/Gemfile
ADD Gemfile.lock /app/Gemfile.lock
RUN bundle install --jobs=8 --without development test
ADD . /app
CMD ["unicorn", "-c", "./config/unicorn.rb"]
CMD ["puma", "-C", "config/puma.rb"]

View File

@ -6,12 +6,12 @@ ruby '2.5.1'
gem 'oj'
gem 'ox'
gem 'puma'
gem 'rack-cors'
gem 'rake'
gem 'rufus-scheduler'
gem 'sequel_pg'
gem 'sinatra'
gem 'unicorn'
group :development do
gem 'guard'

View File

@ -39,7 +39,6 @@ GEM
hashdiff (0.3.7)
http_parser.rb (0.6.0)
jaro_winkler (1.4.0)
kgio (2.11.2)
listen (3.1.5)
rb-fsevent (~> 0.9, >= 0.9.4)
rb-inotify (~> 0.9, >= 0.9.7)
@ -66,6 +65,7 @@ GEM
coderay (~> 1.1.0)
method_source (~> 0.9.0)
public_suffix (3.0.2)
puma (3.11.4)
raabro (1.1.5)
rack (2.0.5)
rack-cors (1.0.2)
@ -76,7 +76,6 @@ GEM
rack-test (1.0.0)
rack (>= 1.0, < 3)
rainbow (3.0.0)
raindrops (0.19.0)
rake (12.3.1)
rb-fsevent (0.10.3)
rb-inotify (0.9.10)
@ -112,9 +111,6 @@ GEM
tzinfo (1.2.5)
thread_safe (~> 0.1)
unicode-display_width (1.4.0)
unicorn (5.4.0)
kgio (~> 2.6)
raindrops (~> 0.7)
vcr (4.0.0)
webmock (3.4.2)
addressable (>= 2.3.6)
@ -133,6 +129,7 @@ DEPENDENCIES
oj
ox
pry
puma
rack-cors
rack-livereload
rack-test
@ -142,7 +139,6 @@ DEPENDENCIES
sequel_pg
shotgun
sinatra
unicorn
vcr
webmock

11
config/puma.rb Normal file
View File

@ -0,0 +1,11 @@
# frozen_string_literal: true
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['APP_ENV'] || 'developments'

View File

@ -1,11 +0,0 @@
# frozen_string_literal: true
worker_process_count = (ENV['WORKER_PROCESSES'] || 4).to_i
preload_app true
worker_processes worker_process_count
timeout 10
before_fork do |_, _|
Sequel::DATABASES.each(&:disconnect)
end

View File

@ -6,7 +6,7 @@ services:
APP_ENV: development
VIRTUAL_HOST: localhost
ports:
- "8080:8080"
- "3000:3000"
scheduler:
build: .
environment:

View File

@ -5,12 +5,12 @@ services:
volumes:
- data:/var/lib/postgresql/data
web:
command: unicorn -c config/unicorn.rb
command: puma -C config/puma.rb
entrypoint: bin/wait-for-it.sh db:5432 -s --
environment:
DATABASE_URL: postgres://postgres@db/postgres
expose:
- '8080'
- '3000'
links:
- db
scheduler: