質問編集履歴

1

puma.rbの提示

2021/11/05 12:26

投稿

yg4yoYYLOO7pqB9
yg4yoYYLOO7pqB9

スコア2

test CHANGED
File without changes
test CHANGED
@@ -140,6 +140,116 @@
140
140
 
141
141
  ```
142
142
 
143
+ config/puma.rb
144
+
145
+ ```
146
+
147
+ # Puma can serve each request in a thread from an internal thread pool.
148
+
149
+ # The `threads` method setting takes two numbers: a minimum and maximum.
150
+
151
+ # Any libraries that use thread pools should be configured to match
152
+
153
+ # the maximum value specified for Puma. Default is set to 5 threads for minimum
154
+
155
+ # and maximum; this matches the default thread size of Active Record.
156
+
157
+ #
158
+
159
+ max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
160
+
161
+ min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
162
+
163
+ threads min_threads_count, max_threads_count
164
+
165
+
166
+
167
+ # Specifies the `port` that Puma will listen on to receive requests; default is 3000.
168
+
169
+ #
170
+
171
+ port ENV.fetch("PORT") { 3000 }
172
+
173
+
174
+
175
+ # Specifies the `environment` that Puma will run in.
176
+
177
+ #
178
+
179
+ environment ENV.fetch("RAILS_ENV") { "development" }
180
+
181
+
182
+
183
+ # Specifies the `pidfile` that Puma will use.
184
+
185
+ pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
186
+
187
+
188
+
189
+ # Specifies the number of `workers` to boot in clustered mode.
190
+
191
+ # Workers are forked web server processes. If using threads and workers together
192
+
193
+ # the concurrency of the application would be max `threads` * `workers`.
194
+
195
+ # Workers do not work on JRuby or Windows (both of which do not support
196
+
197
+ # processes).
198
+
199
+ #
200
+
201
+ # workers ENV.fetch("WEB_CONCURRENCY") { 2 }
202
+
203
+
204
+
205
+ # Use the `preload_app!` method when specifying a `workers` number.
206
+
207
+ # This directive tells Puma to first boot the application and load code
208
+
209
+ # before forking the application. This takes advantage of Copy On Write
210
+
211
+ # process behavior so workers use less memory.
212
+
213
+ #
214
+
215
+ # preload_app!
216
+
217
+
218
+
219
+ # Allow puma to be restarted by `rails restart` command.
220
+
221
+ plugin :tmp_restart
222
+
223
+ bind "unix://#{Rails.root}/tmp/sockets/puma.sock"
224
+
225
+ rails_root = Dir.pwd
226
+
227
+ # 本番環境のみデーモン起動
228
+
229
+ if Rails.env.production?
230
+
231
+ pidfile File.join(rails_root, 'tmp', 'pids', 'puma.pid')
232
+
233
+ state_path File.join(rails_root, 'tmp', 'pids', 'puma.state')
234
+
235
+ stdout_redirect(
236
+
237
+ File.join(rails_root, 'log', 'puma.log'),
238
+
239
+ File.join(rails_root, 'log', 'puma-error.log'),
240
+
241
+ true
242
+
243
+ )
244
+
245
+ # デーモン
246
+
247
+ daemonize
248
+
249
+ end
250
+
251
+ ```
252
+
143
253
  ##試したこと
144
254
 
145
255
  まずssl化を実装するためにやったことは以下です