Sha256: 281a4fc1fc008c4ec4109611766ed7f1a0657f5353f14c100bd80a3748bb10f6

Contents?: true

Size: 1.31 KB

Versions: 12

Compression:

Stored size: 1.31 KB

Contents

# frozen_string_literal: true

#
# Environment and port
#
port ENV.fetch("<%= Hanami::Port::ENV_VAR %>", <%= Hanami::Port::DEFAULT %>)
environment ENV.fetch("HANAMI_ENV", "development")

#
# Threads within each Puma/Ruby process (aka worker)
#

# Configure the minimum and maximum number of threads to use to answer requests.
max_threads_count = ENV.fetch("HANAMI_MAX_THREADS", 5)
min_threads_count = ENV.fetch("HANAMI_MIN_THREADS") { max_threads_count }

threads min_threads_count, max_threads_count

#
# Workers (aka Puma/Ruby processes)
#

puma_concurrency = Integer(ENV.fetch("HANAMI_WEB_CONCURRENCY", 0))
puma_cluster_mode = puma_concurrency > 1

# How many worker (Puma/Ruby) processes to run.
# Typically this is set to the number of available cores.
workers puma_concurrency

#
# Cluster mode (aka multiple workers)
#

if puma_cluster_mode
  # Preload the application before starting the workers. Only in cluster mode.
  preload_app!

  # Code to run immediately before master process forks workers (once on boot).
  #
  # These hooks can block if necessary to wait for background operations unknown
  # to puma to finish before the process terminates. This can be used to close
  # any connections to remote servers (database, redis, …) that were opened when
  # preloading the code.
  before_fork do
    Hanami.shutdown
  end
end

Version data entries

12 entries across 12 versions & 2 rubygems

Version Path
hanami-cli-2.2.1 lib/hanami/cli/generators/gem/app/puma.erb
hanami-cli-2.2.0 lib/hanami/cli/generators/gem/app/puma.erb
hanami-cli-2.2.0.rc1 lib/hanami/cli/generators/gem/app/puma.erb
hanami-cli_bulma-0.0.2 lib/hanami/cli_bulma/generators/gem/app/puma.erb
hanami-cli_bulma-0.0.1 lib/hanami/cli_bulma/generators/gem/app/puma.erb
hanami-cli-2.2.0.beta2 lib/hanami/cli/generators/gem/app/puma.erb
hanami-cli-2.2.0.beta1 lib/hanami/cli/generators/gem/app/puma.erb
hanami-cli-2.1.1 lib/hanami/cli/generators/gem/app/puma.erb
hanami-cli-2.1.0 lib/hanami/cli/generators/gem/app/puma.erb
hanami-cli-2.1.0.rc3 lib/hanami/cli/generators/gem/app/puma.erb
hanami-cli-2.1.0.rc2 lib/hanami/cli/generators/gem/app/puma.erb
hanami-cli-2.1.0.rc1 lib/hanami/cli/generators/gem/app/puma.erb