handle missing database configuration

pull/9732/head
Markus Kahl 3 years ago
parent 116f57acbd
commit 3d0776c28f
  1. 6
      config/initializers/database_pool_size.rb

@ -1,8 +1,8 @@
config = Rails.application.config.database_configuration[Rails.env]
pool_size = [OpenProject::Configuration.web_max_threads + 1, config['pool'].to_i].max
config = Rails.env.production? && Rails.application.config.database_configuration[Rails.env]
pool_size = config && [OpenProject::Configuration.web_max_threads + 1, config['pool'].to_i].max
# make sure we have enough connections in the pool for each thread and then some
if Rails.env.production? && pool_size > ActiveRecord::Base.connection_pool.size
if pool_size && pool_size > ActiveRecord::Base.connection_pool.size
Rails.logger.debug { "Increasing database pool size to #{pool_size} to match max threads" }
ActiveRecord::Base.establish_connection config.merge(pool: pool_size)

Loading…
Cancel
Save