workers Integer(ENV["PUMA_WORKERS"] || 1)
threads Integer(ENV["MIN_THREADS"]  || 1), Integer(ENV["MAX_THREADS"] || 16)

preload_app!

rackup      DefaultRackup
port        ENV["PORT"]     || 5000
environment ENV["RACK_ENV"] || "development"

on_worker_boot do
  ActiveSupport.on_load(:active_record) do
    config = ActiveRecord::Base.configurations[ENV["RACK_ENV"]]

    if config
      config["pool"] = ENV["MAX_THREADS"] || 16
      ActiveRecord::Base.establish_connection(config)
    end
  end
end