This commit is contained in:
Mark Tareshawty 2018-03-11 15:39:55 -04:00
Родитель 75f7ff580c
Коммит 9ddc682673
Не найден ключ, соответствующий данной подписи
Идентификатор ключа GPG: 28DD1C473BF9D1AE
5 изменённых файлов: 61 добавлений и 30 удалений

Просмотреть файл

@ -9,11 +9,11 @@ gem 'redis-rails'
gem 'faraday'
gem 'faraday_middleware'
gem 'octokit'
gem 'puma'
gem "pg", '0.21.0'
gem 'rack-timeout'
gem 'tilt'
gem 'tire'
gem 'unicorn'
gem 'iso8601'
gem 'json'

Просмотреть файл

@ -106,7 +106,6 @@ GEM
railties (>= 4.2.0)
thor (>= 0.14, < 2.0)
json (2.1.0)
kgio (2.11.2)
launchy (2.4.3)
addressable (~> 2.3)
loofah (2.2.0)
@ -134,6 +133,7 @@ GEM
byebug (~> 10.0)
pry (~> 0.10)
public_suffix (3.0.2)
puma (3.11.3)
rack (1.6.9)
rack-test (0.6.3)
rack (>= 1.0)
@ -168,7 +168,6 @@ GEM
activesupport (= 4.2.10)
rake (>= 0.8.7)
thor (>= 0.18.1, < 2.0)
raindrops (0.19.0)
rake (12.3.0)
redcarpet (3.4.0)
redis (4.0.1)
@ -251,9 +250,6 @@ GEM
unf (0.1.4)
unf_ext
unf_ext (0.0.7.5)
unicorn (5.4.0)
kgio (~> 2.6)
raindrops (~> 0.7)
uniform_notifier (1.11.0)
vcr (4.0.0)
webmock (3.3.0)
@ -289,6 +285,7 @@ DEPENDENCIES
octokit
pg (= 0.21.0)
pry-byebug
puma
rack-timeout
rails (= 4.2.10)
rails-perftest
@ -304,7 +301,6 @@ DEPENDENCIES
tilt
tire
uglifier
unicorn
vcr
webmock
yajl-ruby

Просмотреть файл

@ -1 +1 @@
web: bundle exec unicorn -p $PORT -c ./config/unicorn.rb
web: bundle exec puma -C config/puma.rb

57
config/puma.rb Normal file
Просмотреть файл

@ -0,0 +1,57 @@
# frozen_string_literal: true
# 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 = Integer(ENV.fetch('RAILS_MAX_THREADS') { 5 })
threads threads_count, threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 5000.
#
port ENV.fetch('PORT') { 5000 }
# 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 Integer(ENV.fetch('WEB_CONCURRENCY') { 3 })
# 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!
# If you are preloading your application and using Active Record, it's
# recommended that you close any connections to the database before workers
# are forked to prevent connection leakage.
#
before_fork do
ActiveRecord::Base.connection_pool.disconnect! if defined?(ActiveRecord)
end
# 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 the `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, as 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

Просмотреть файл

@ -1,22 +0,0 @@
worker_processes Integer(ENV["WEB_CONCURRENCY"] || 3)
timeout 15
preload_app true
before_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn master intercepting TERM and sending myself QUIT instead'
Process.kill 'QUIT', Process.pid
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.connection.disconnect!
end
after_fork do |server, worker|
Signal.trap 'TERM' do
puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT'
end
defined?(ActiveRecord::Base) and
ActiveRecord::Base.establish_connection
end