2019-07-30 21:29:24 +00:00
|
|
|
# frozen_string_literal: true
|
|
|
|
|
2018-03-25 16:15:39 +00:00
|
|
|
# License: AGPL-3.0-or-later WITH Web-Template-Output-Additional-Permission-3.0-or-later
|
2019-02-01 17:54:16 +00:00
|
|
|
|
|
|
|
# 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.
|
|
|
|
#
|
2019-07-30 21:29:24 +00:00
|
|
|
threads_count = ENV.fetch('RAILS_MAX_THREADS') { 5 }.to_i
|
2019-02-01 17:54:16 +00:00
|
|
|
threads threads_count, threads_count
|
|
|
|
|
2018-03-25 17:30:42 +00:00
|
|
|
preload_app! if ENV['RAILS_ENV'] != 'development'
|
|
|
|
|
|
|
|
rackup DefaultRackup
|
2019-07-30 21:29:24 +00:00
|
|
|
port ENV.fetch('PORT') { 5000 }
|
|
|
|
environment ENV.fetch('RAILS_ENV') { 'development' }
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-07-13 07:51:00 +00:00
|
|
|
workers Integer(ENV['WEB_CONCURRENCY'] || 1)
|
2018-03-25 17:30:42 +00:00
|
|
|
|
2019-02-01 17:54:16 +00:00
|
|
|
on_worker_boot do
|
|
|
|
# ActiveSupport.on_load(:active_record) do
|
|
|
|
# config = ActiveRecord::Base.configurations[Rails.env] ||
|
|
|
|
# Rails.application.config.database_configuration[Rails.env]
|
|
|
|
# config['pool'] = ENV['RAILS_MAX_THREADS'] || 1
|
|
|
|
# ActiveRecord::Base.establish_connection
|
|
|
|
# end
|
|
|
|
ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
|
2018-03-25 17:30:42 +00:00
|
|
|
end
|
|
|
|
|
2019-02-01 17:54:16 +00:00
|
|
|
# Allow puma to be restarted by `rails restart` command.
|
|
|
|
plugin :tmp_restart
|