Bring app in line with Hanami 2.1.0 base

This commit is contained in:
2023-11-18 08:49:08 +11:00
parent e1a230bdba
commit 484259fab1
24 changed files with 232 additions and 220 deletions

View File

@@ -24,13 +24,17 @@ Hanami.app.register_provider :persistence, namespace: true do
start do
rom_config = target["persistence.config"]
rom_config.auto_registration(
target.root.join("lib/adamantium/persistence"),
namespace: "Adamantium::Persistence"
target.root.join("app"),
namespace: Hanami.app.namespace.to_s
)
register "rom", ROM.container(rom_config)
end
stop do
target["persistence.rom"].disconnect
end
define_method(:silence_warnings) do |&block|
orig_verbose = $VERBOSE
$VERBOSE = nil

View File

@@ -1,17 +1,47 @@
# frozen_string_literal: true
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
#
# Environment and port
#
port ENV.fetch("HANAMI_PORT", 2300)
environment ENV.fetch("HANAMI_ENV", "development")
workers ENV.fetch("HANAMI_WEB_CONCURRENCY", 2)
on_worker_boot do
Hanami.shutdown
end
#
# Threads within each Puma/Ruby process (aka worker)
#
pidfile ENV.fetch("PIDFILE", "tmp/pids/puma.pid")
# 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 }
preload_app!
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