annotate config/puma.rb @ 442:1fc5ddcde386

Some refactors
author nanaya <me@myconan.net>
date Thu, 10 Nov 2016 21:58:25 +0900
parents 68eb23b52864
children
Ignore whitespace changes - Everywhere: Within whitespace: At end of lines:
rev   line source
431
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
1 # Puma can serve each request in a thread from an internal thread pool.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
2 # The `threads` method setting takes two numbers a minimum and maximum.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
3 # Any libraries that use thread pools should be configured to match
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
4 # the maximum value specified for Puma. Default is set to 5 threads for minimum
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
5 # and maximum, this matches the default thread size of Active Record.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
6 #
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
7 threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
8 threads threads_count, threads_count
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
9
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
10 # Specifies the `port` that Puma will listen on to receive requests, default is 3000.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
11 #
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
12 port ENV.fetch("PORT") { 3000 }
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
13
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
14 # Specifies the `environment` that Puma will run in.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
15 #
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
16 environment ENV.fetch("RAILS_ENV") { "development" }
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
17
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
18 # Specifies the number of `workers` to boot in clustered mode.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
19 # Workers are forked webserver processes. If using threads and workers together
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
20 # the concurrency of the application would be max `threads` * `workers`.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
21 # Workers do not work on JRuby or Windows (both of which do not support
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
22 # processes).
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
23 #
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
24 # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
25
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
26 # Use the `preload_app!` method when specifying a `workers` number.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
27 # This directive tells Puma to first boot the application and load code
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
28 # before forking the application. This takes advantage of Copy On Write
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
29 # process behavior so workers use less memory. If you use this option
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
30 # you need to make sure to reconnect any threads in the `on_worker_boot`
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
31 # block.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
32 #
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
33 # preload_app!
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
34
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
35 # The code in the `on_worker_boot` will be called if you are using
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
36 # clustered mode by specifying a number of `workers`. After each worker
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
37 # process is booted this block will be run, if you are using `preload_app!`
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
38 # option you will want to use this block to reconnect to any threads
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
39 # or connections that may have been created at application boot, Ruby
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
40 # cannot share connections between processes.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
41 #
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
42 # on_worker_boot do
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
43 # ActiveRecord::Base.establish_connection if defined?(ActiveRecord)
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
44 # end
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
45
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
46 # Allow puma to be restarted by `rails restart` command.
68eb23b52864 Rails 5 \o/
nanaya <me@myconan.net>
parents:
diff changeset
47 plugin :tmp_restart