diff --git a/Procfile b/Procfile index 35c48c6..c2c566e 100644 --- a/Procfile +++ b/Procfile @@ -1 +1 @@ -web: bundle exec puma -p $PORT -e $RACK_ENV -t 0:5 +web: bundle exec puma -C config/puma.rb diff --git a/config/puma.rb b/config/puma.rb new file mode 100644 index 0000000..2e49738 --- /dev/null +++ b/config/puma.rb @@ -0,0 +1,18 @@ +workers Integer(ENV['PUMA_WORKERS'] || 3) +threads Integer(ENV['MIN_THREADS'] || 1), Integer(ENV['MAX_THREADS'] || 16) + +preload_app! + +rackup DefaultRackup +port ENV['PORT'] || 3000 +environment ENV['RACK_ENV'] || 'development' + +on_worker_boot do + # worker specific setup + ActiveSupport.on_load(:active_record) do + config = ActiveRecord::Base.configurations[Rails.env] || + Rails.application.config.database_configuration[Rails.env] + config['pool'] = ENV['MAX_THREADS'] || 16 + ActiveRecord::Base.establish_connection(config) + end +end