Created
March 29, 2014 14:09
-
-
Save swalberg/9855092 to your computer and use it in GitHub Desktop.
Revisions
-
steakknife revised this gist
Mar 28, 2014 . 1 changed file with 2 additions and 0 deletions.There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -1,3 +1,5 @@ # doc # https://github.com/puma/puma/blob/master/examples/config.rb max_threads = Integer(ENV['PUMA_MAX_THREADS'] || '16') threads Integer(ENV['PUMA_MIN_THREADS'] || '0'), max_threads workers Integer(ENV['PUMA_WORKERS'] || '1') -
steakknife created this gist
Mar 28, 2014 .There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,23 @@ module MyApp module Database def connect(pool_size = nil, reap_time = nil) return unless defined? ActiveRecord::Base config = Rails.application.config.database_configuration[Rails.env] config['reaping_frequency'] = reap_time || ENV['AR_DB_REAP_FREQ'] || 10 # seconds config['pool'] = pool_size || ENV['AR_DB_POOL'] || 5 ActiveRecord::Base.establish_connection(config) end def disconnect return unless defined? ActiveRecord::Base ActiveRecord::Base.connection_pool.disconnect! end def reconnect(pool_size = nil, reap_time = nil) disconnect connect(pool_size, reap_time) end module_function :disconnect, :connect, :reconnect end end This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters. Learn more about bidirectional Unicode charactersOriginal file line number Diff line number Diff line change @@ -0,0 +1,24 @@ max_threads = Integer(ENV['PUMA_MAX_THREADS'] || '16') threads Integer(ENV['PUMA_MIN_THREADS'] || '0'), max_threads workers Integer(ENV['PUMA_WORKERS'] || '1') require './lib/config/active_record' on_worker_boot do ActiveSupport.on_load(:active_record) do MyApp::Database.reconnect(max_threads) end end if ENV['PUMA_CONTROL_ENDPOINT'] if ENV['PUMA_CONTROL_ENDPOINT_AUTH_TOKEN'] activate_control_app ENV['PUMA_CONTROL_ENDPOINT'], { auth_token: ENV['PUMA_CONTROL_ENDPOINT_AUTH_TOKEN'] } elsif ENV['PUMA_CONTROL_ENDPOINT_NO_AUTH_TOKEN'] activate_control_app ENV['PUMA_CONTROL_ENDPOINT'], { no_token: true } else activate_control_app ENV['PUMA_CONTROL_ENDPOINT'] end end preload_app! ENV['PUMA_LOADED'] = 'y'