✨ Recognize teammates in slack by awarding them sparkles!
1# frozen_string_literal: true
2
3#
4# Environment and port
5#
6port ENV.fetch("HANAMI_PORT", 2300)
7environment ENV.fetch("HANAMI_ENV", "development")
8
9#
10# Threads within each Puma/Ruby process (aka worker)
11#
12
13# Configure the minimum and maximum number of threads to use to answer requests.
14max_threads_count = ENV.fetch("HANAMI_MAX_THREADS", 5)
15min_threads_count = ENV.fetch("HANAMI_MIN_THREADS") { max_threads_count }
16
17threads min_threads_count, max_threads_count
18
19#
20# Workers (aka Puma/Ruby processes)
21#
22
23puma_concurrency = Integer(ENV.fetch("HANAMI_WEB_CONCURRENCY", 0))
24puma_cluster_mode = puma_concurrency > 1
25
26# How many worker (Puma/Ruby) processes to run.
27# Typically this is set to the number of available cores.
28workers puma_concurrency
29
30#
31# Cluster mode (aka multiple workers)
32#
33
34if puma_cluster_mode
35 # Preload the application before starting the workers. Only in cluster mode.
36 preload_app!
37
38 # Code to run immediately before master process forks workers (once on boot).
39 #
40 # These hooks can block if necessary to wait for background operations unknown
41 # to puma to finish before the process terminates. This can be used to close
42 # any connections to remote servers (database, redis, …) that were opened when
43 # preloading the code.
44 before_fork do
45 Hanami.shutdown
46 end
47end