Sha256: 8a76a16ccbd2124fbabb8766db2a5238326e87ed03a757bb4957271b7fddfb81

Contents?: true

Size: 1.23 KB

Versions: 1

Compression:

Stored size: 1.23 KB

Contents

module PublishingPlatformPuma
  def self.configure_rails(config)
    config.port ENV.fetch("PORT", 3000)

    config.environment ENV.fetch("RAILS_ENV", "development")

    # `worker_timeout` specifies how many seconds Puma will wait before terminating a worker.
    timeout = if ENV.fetch("RAILS_ENV", "development") == "development"
                3600
              else
                Integer(ENV.fetch("PUMA_TIMEOUT", 15))
              end
    config.worker_timeout timeout

    # When changing the min/max threads for Puma, also consider changing ActiveRecord to match.
    max_threads_count = ENV.fetch("RAILS_MAX_THREADS", 5)
    min_threads_count = ENV.fetch("RAILS_MIN_THREADS", max_threads_count)
    config.threads min_threads_count, max_threads_count

    # `workers` specifies the number of worker processes that Puma will fork.
    # The overall concurrency limit is worker count * max threads per worker.
    config.workers ENV.fetch("WEB_CONCURRENCY", 2)

    # `preload_app!` tells Puma to load application code before forking worker processes.
    # This reduces RAM wastage by making better use of copy-on-write.
    config.preload_app!

    # Allow puma to be restarted by `rails restart` command.
    config.plugin :tmp_restart
  end
end

Version data entries

1 entries across 1 versions & 1 rubygems

Version Path
publishing_platform_app_config-0.3.0 lib/publishing_platform_app_config/publishing_platform_puma.rb