質問編集履歴

3

これまでのログと、自分で試してみたことについてなどを追記

2020/09/22 05:44

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- 【Rails】ログ意味を教えてださ
1
+ 本番環境設定がうまくいきません
test CHANGED
@@ -1,16 +1,26 @@
1
- ###知りたいこと
1
+ ##知りたいこと
2
2
 
3
3
 
4
4
 
5
5
  EC2にRailsアプリの本番環境を構築しています。
6
6
 
7
- `unicorn`の起動の際にエラーしまうのですが、ログの英語を翻訳しても意味よくわらず、原因を探れないます。
7
+ ウェブサーバーを起動できない問題発生しおり、ログを見るにおそらく設定記述どこ間違えてるのだと思います。
8
+
9
+
10
+
8
-
11
+ 調べてみても`unicorn`+`nginx`という同じ組み合わせでも記述が異なっていたりして、どこが間違えているのか理解することができませんでした。
12
+
13
+
14
+
9
-
15
+ 頼り方が安易で大変失礼とは承知なのですが、設定ファイルの中身を添削していただけませんでしょうか。
10
-
16
+
17
+
18
+
11
- ###実行したコマンド
19
+ ##起きている問題
20
+
21
+
22
+
12
-
23
+ ###1、`unicorn`が起動できない
13
-
14
24
 
15
25
  ```
16
26
 
@@ -18,17 +28,15 @@
18
28
 
19
29
  ```
20
30
 
21
-
31
+ ▼エラーメッセージ
22
-
23
-
24
-
25
-
26
-
32
+
27
- ###ログ
33
+ ```
34
+
28
-
35
+ master failed to start, check stderr log for details
36
+
29
-
37
+ ```
30
-
38
+
31
- 以下、`unicorn.stderr.log`の中身です。
39
+ ▼ログ(`unicorn.stderr.log`)
32
40
 
33
41
 
34
42
 
@@ -40,123 +48,583 @@
40
48
 
41
49
  1001 NoMethodError: undefined method `fetch' for #<アプリ名::Application:0x0000000003f5d1a8>
42
50
 
43
- 1002 /var/www/アプリ名/config/environments/production.rb:17:in `block in <main>'
44
-
45
- 1003 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/railtie.rb:216:in `instance_eval'
46
-
47
- 1004 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/railtie.rb:216:in `configure'
48
-
49
- 1005 /var/www/アプリ名/config/environments/production.rb:1:in `<main>'
50
-
51
- 1006 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `require'
52
-
53
- 1007 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:23:in `block in require_with_bootsnap_lfi'
54
-
55
- 1008 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/loaded_features_index.rb:92:in `register'
56
-
57
- 1009 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:22:in `require_with_bootsnap_lfi'
58
-
59
- 1010 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/bootsnap-1.4.8/lib/bootsnap/load_path_cache/core_ext/kernel_require.rb:31:in `require'
60
-
61
- 1011 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:34:in `require'
62
-
63
- 1012 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `block in require'
64
-
65
- 1013 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:291:in `load_dependency'
66
-
67
- 1014 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/activesupport-6.0.3.2/lib/active_support/dependencies.rb:324:in `require'
68
-
69
- 1015 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/engine.rb:613:in `block (2 levels) in <class:Engine>'
70
-
71
- 1016 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/engine.rb:612:in `each'
72
-
73
- 1017 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/engine.rb:612:in `block in <class:Engine>'
74
-
75
- 1018 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:32:in `instance_exec'
76
-
77
- 1019 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:32:in `run'
78
-
79
- 1020 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:61:in `block in run_initializers'
80
-
81
- 1021 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:228:in `block in tsort_each'
82
-
83
- 1022 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:350:in `block (2 levels) in each_strongly_connected_component'
84
-
85
- 1023 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:422:in `block (2 levels) in each_strongly_connected_component_from'
86
-
87
- 1024 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:431:in `each_strongly_connected_component_from'
88
-
89
- 1025 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:421:in `block in each_strongly_connected_component_from'
90
-
91
- 1026 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:50:in `each'
92
-
93
- 1027 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:50:in `tsort_each_child'
94
-
95
- 1028 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:415:in `call'
96
-
97
- 1029 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:415:in `each_strongly_connected_component_from'
98
-
99
- 1030 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:349:in `block in each_strongly_connected_component'
100
-
101
- 1031 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:347:in `each'
102
-
103
- 1032 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:347:in `call'
104
-
105
- 1033 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:347:in `each_strongly_connected_component'
106
-
107
- 1034 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:226:in `tsort_each'
108
-
109
- 1035 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/2.6.0/tsort.rb:205:in `tsort_each'
110
-
111
- 1036 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/initializable.rb:60:in `run_initializers'
112
-
113
- 1037 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/railties-6.0.3.2/lib/rails/application.rb:363:in `initialize!'
114
-
115
- 1038 /var/www/filma/config/environment.rb:5:in `<top (required)>'
116
-
117
- 1039 config.ru:4:in `require_relative'
118
-
119
- 1040 config.ru:4:in `block in <main>'
120
-
121
- 1041 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in `instance_eval'
122
-
123
- 1042 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/rack-2.2.3/lib/rack/builder.rb:125:in `initialize'
124
-
125
- 1043 config.ru:1:in `new'
126
-
127
- 1044 config.ru:1:in `<main>'
128
-
129
- 1045 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn.rb:56:in `eval'
130
-
131
- 1046 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn.rb:56:in `block in builder'
132
-
133
- 1047 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:139:in `block in rails_builder'
134
-
135
- 1048 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:795:in `build_app!'
136
-
137
- 1049 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:139:in `start'
138
-
139
- 1050 /home/ec2-user/.rbenv/versions/2.6.6/lib/ruby/gems/2.6.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>'
140
-
141
- 1051 /home/ec2-user/.rbenv/versions/2.6.6/bin/unicorn_rails:23:in `load'
142
-
143
- 1052 /home/ec2-user/.rbenv/versions/2.6.6/bin/unicorn_rails:23:in `<top (required)>'
144
-
145
- ```
146
-
147
-
148
-
149
- ###NoMethodError
150
-
151
-
152
-
153
- 一番上の行には**"fetch"というメソッドはない**というようなことが書いてありますが、`fetch`はRubyに標準で備わっているメソッドではないかと思うのですが…どうしてそんなエラーが出てしまうのかわかりません。
154
-
155
-
156
-
157
- お分かりの方がいらっしゃいましたら、このログの読み方を教えてください。
158
-
159
- お願いいたします。
51
+
52
+
53
+
54
+
55
+
56
+
57
+ ```
58
+
59
+
60
+
61
+ ###2、データベースを作成できない
62
+
63
+
64
+
65
+ ```
66
+
67
+ rails db:create RAILS_ENV=production
68
+
69
+ ```
70
+
71
+ ▼エラーメッセージ
72
+
73
+ ```
74
+
75
+ rails aborted!
76
+
77
+ NoMethodError: undefined method `fetch' for #<アプリ名::Application:0x00000000023c9ab8>
78
+
79
+ /var/www/アプリ名/config/environments/production.rb:17:in `block in <main>'
80
+
81
+ /var/www/アプリ名/config/environments/production.rb:1:in `<main>'
82
+
83
+ /var/www/アプリ名/config/environment.rb:5:in `<main>'
84
+
85
+ bin/rails:4:in `<main>'
86
+
87
+ Tasks: TOP => db:create => db:load_config => environment
88
+
89
+ (See full trace by running task with --trace)
90
+
91
+ ```
92
+
93
+ ---
94
+
95
+
96
+
97
+
98
+
99
+ 他にも`unicorn`の起動に関しては、`Cannot load database configuration:`というエラーが出たことがあったり、
100
+
101
+
102
+
103
+ ```
104
+
105
+ I, [2020-09-19T07:00:51.913723 #9104] INFO -- : Refreshing Gem list
106
+
107
+ bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.6.6/bin/unicorn_rails)
108
+
109
+ ActiveSupport::MessageEncryptor::InvalidMessage: Cannot load database configuration:
110
+
111
+ ActiveSupport::MessageEncryptor::InvalidMessage
112
+
113
+
114
+
115
+
116
+
117
+
118
+
119
+ ```
120
+
121
+
122
+
123
+ 今日試した時には`NoDatabaseError`も発生しています。
124
+
125
+
126
+
127
+ ```
128
+
129
+ I, [2020-09-22T04:42:19.543564 #2605] INFO -- : Refreshing Gem list
130
+
131
+ I, [2020-09-22T04:42:20.452976 #2605] INFO -- : listening on addr=0.0.0.0:3000 fd=9
132
+
133
+ E, [2020-09-22T04:42:20.454887 #2605] ERROR -- : Unknown database 'アプリ名_production' (ActiveRecord::NoDatabaseError)
134
+
135
+
136
+
137
+
138
+
139
+
140
+
141
+ ```
142
+
143
+
144
+
145
+ ###各設定ファイル
146
+
147
+
148
+
149
+ 多分それぞれ原因は同じで、`production.rb`や`database.yml`、`unicorn.rb`などのいずれかが間違えているのではないかと思います。
150
+
151
+ 以下関係ありそうなファイルです。
152
+
153
+
154
+
155
+ ```
156
+
157
+ production.rb
158
+
159
+
160
+
161
+ Rails.application.configure do
162
+
163
+ # Settings specified here will take precedence over those in config/application.rb.
164
+
165
+
166
+
167
+ # Code is not reloaded between requests.
168
+
169
+ config.cache_classes = true
170
+
171
+
172
+
173
+ # Eager load code on boot. This eager loads most of Rails and
174
+
175
+ # your application in memory, allowing both threaded web servers
176
+
177
+ # and those relying on copy on write to perform better.
178
+
179
+ # Rake tasks automatically ignore this option for performance.
180
+
181
+ config.eager_load = true
182
+
183
+
184
+
185
+ # Full error reports are disabled and caching is turned on.
186
+
187
+ config.consider_all_requests_local = false
188
+
189
+ config.action_controller.perform_caching = true
190
+
191
+
192
+
193
+
194
+
195
+
196
+
197
+
198
+
199
+ # Ensures that a master key has been made available in either ENV["RAILS_MASTER_KEY"]
200
+
201
+ # or in config/master.key. This key is used to decrypt credentials (and other encrypted files).
202
+
203
+ config.require_master_key = true
204
+
205
+
206
+
207
+ # Disable serving static files from the `/public` folder by default since
208
+
209
+ # Apache or NGINX already handles this.
210
+
211
+ config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
212
+
213
+
214
+
215
+ # Compress CSS using a preprocessor.
216
+
217
+ # config.assets.css_compressor = :sass
218
+
219
+
220
+
221
+ # Do not fallback to assets pipeline if a precompiled asset is missed.
222
+
223
+ config.assets.compile = false
224
+
225
+
226
+
227
+ # Enable serving of images, stylesheets, and JavaScripts from an asset server.
228
+
229
+ # config.action_controller.asset_host = 'http://assets.example.com'
230
+
231
+
232
+
233
+ # Specifies the header that your server uses for sending files.
234
+
235
+ # config.action_dispatch.x_sendfile_header = 'X-Sendfile' # for Apache
236
+
237
+ # config.action_dispatch.x_sendfile_header = 'X-Accel-Redirect' # for NGINX
238
+
239
+
240
+
241
+ # Store uploaded files on the local file system (see config/storage.yml for options).
242
+
243
+ config.active_storage.service = :local
244
+
245
+
246
+
247
+ # Mount Action Cable outside main process or domain.
248
+
249
+ # config.action_cable.mount_path = nil
250
+
251
+ # config.action_cable.url = 'wss://example.com/cable'
252
+
253
+ # config.action_cable.allowed_request_origins = [ 'http://example.com', /http://example.*/ ]
254
+
255
+
256
+
257
+ # Force all access to the app over SSL, use Strict-Transport-Security, and use secure cookies.
258
+
259
+ # config.force_ssl = true
260
+
261
+
262
+
263
+ # Use the lowest log level to ensure availability of diagnostic information
264
+
265
+ # when problems arise.
266
+
267
+ config.log_level = :debug
268
+
269
+
270
+
271
+ # Prepend all log lines with the following tags.
272
+
273
+ config.log_tags = [ :request_id ]
274
+
275
+
276
+
277
+ # Use a different cache store in production.
278
+
279
+ # config.cache_store = :mem_cache_store
280
+
281
+
282
+
283
+ # Use a real queuing backend for Active Job (and separate queues per environment).
284
+
285
+ # config.active_job.queue_adapter = :resque
286
+
287
+ # config.active_job.queue_name_prefix = "アプリ名_production"
288
+
289
+
290
+
291
+ config.action_mailer.perform_caching = false
292
+
293
+
294
+
295
+ # Ignore bad email addresses and do not raise email delivery errors.
296
+
297
+ # Set this to true and configure the email server for immediate delivery to raise delivery errors.
298
+
299
+ # config.action_mailer.raise_delivery_errors = false
300
+
301
+
302
+
303
+ # Enable locale fallbacks for I18n (makes lookups for any locale fall back to
304
+
305
+ # the I18n.default_locale when a translation cannot be found).
306
+
307
+ config.i18n.fallbacks = true
308
+
309
+
310
+
311
+ # Send deprecation notices to registered listeners.
312
+
313
+ config.active_support.deprecation = :notify
314
+
315
+
316
+
317
+ # Use default logging formatter so that PID and timestamp are not suppressed.
318
+
319
+ config.log_formatter = ::Logger::Formatter.new
320
+
321
+
322
+
323
+ # Use a different logger for distributed setups.
324
+
325
+ # require 'syslog/logger'
326
+
327
+ # config.logger = ActiveSupport::TaggedLogging.new(Syslog::Logger.new 'app-name')
328
+
329
+
330
+
331
+ if ENV["RAILS_LOG_TO_STDOUT"].present?
332
+
333
+ logger = ActiveSupport::Logger.new(STDOUT)
334
+
335
+ logger.formatter = config.log_formatter
336
+
337
+ config.logger = ActiveSupport::TaggedLogging.new(logger)
338
+
339
+ end
340
+
341
+
342
+
343
+ # Do not dump schema after migrations.
344
+
345
+ config.active_record.dump_schema_after_migration = false
346
+
347
+
348
+
349
+ # Inserts middleware to perform automatic connection switching.
350
+
351
+ # The `database_selector` hash is used to pass options to the DatabaseSelector
352
+
353
+ # middleware. The `delay` is used to determine how long to wait after a write
354
+
355
+ # to send a subsequent read to the primary.
356
+
357
+ #
358
+
359
+ # The `database_resolver` class is used by the middleware to determine which
360
+
361
+ # database is appropriate to use based on the time delay.
362
+
363
+ #
364
+
365
+ # The `database_resolver_context` class is used by the middleware to set
366
+
367
+ # timestamps for the last write to the primary. The resolver uses the context
368
+
369
+ # class timestamps to determine how long to wait before reading from the
370
+
371
+ # replica.
372
+
373
+ #
374
+
375
+ # By default Rails will store a last write timestamp in the session. The
376
+
377
+ # DatabaseSelector middleware is designed as such you can define your own
378
+
379
+ # strategy for connection switching and pass that into the middleware through
380
+
381
+ # these configuration options.
382
+
383
+ # config.active_record.database_selector = { delay: 2.seconds }
384
+
385
+ # config.active_record.database_resolver = ActiveRecord::Middleware::DatabaseSelector::Resolver
386
+
387
+ # config.active_record.database_resolver_context = ActiveRecord::Middleware::DatabaseSelector::Resolver::Session
388
+
389
+ end
390
+
391
+ ```
392
+
393
+
394
+
395
+ ```
396
+
397
+ database.yml
398
+
399
+
400
+
401
+ default: &default
402
+
403
+ adapter: mysql2
404
+
405
+ pool: 5 
406
+
407
+ timeout: 5000
408
+
409
+ encording: utf8
410
+
411
+ database: アプリ名
412
+
413
+ username: root
414
+
415
+ password: パスワード
416
+
417
+ host: localhost
418
+
419
+
420
+
421
+
422
+
423
+
424
+
425
+
426
+
427
+
428
+
429
+ production:
430
+
431
+ <<: *default
432
+
433
+ database: アプリ名_production
434
+
435
+ username: root
436
+
437
+ password: パスワード
438
+
439
+ encoding: utf8
440
+
441
+ host: localhost
442
+
443
+ ```
444
+
445
+
446
+
447
+ ```
448
+
449
+ credentials.yml
450
+
451
+
452
+
453
+ db:
454
+
455
+ database: アプリ名
456
+
457
+ username: root
458
+
459
+ password: パスワード
460
+
461
+ socket: /var/lib/mysql/mysql.sock
462
+
463
+
464
+
465
+ (シークレットキー)
466
+
467
+ ```
468
+
469
+
470
+
471
+ ```
472
+
473
+ unicorn.rb
474
+
475
+
476
+
477
+ app_path = File.expand_path('../../', __FILE__)
478
+
479
+
480
+
481
+ worker_processes 1
482
+
483
+
484
+
485
+
486
+
487
+ working_directory app_path
488
+
489
+
490
+
491
+ pid "#{app_path}/tmp/pids/unicorn.pid"
492
+
493
+
494
+
495
+ listen 3000
496
+
497
+
498
+
499
+ stderr_path "#{app_path}/log/unicorn.stderr.log"
500
+
501
+
502
+
503
+ stdout_path "#{app_path}/log/unicorn.stdout.log"
504
+
505
+
506
+
507
+ timeout 60
508
+
509
+
510
+
511
+ preload_app true
512
+
513
+ GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true
514
+
515
+
516
+
517
+ check_client_connection false
518
+
519
+
520
+
521
+ run_once = true
522
+
523
+
524
+
525
+ before_fork do |server, worker|
526
+
527
+ defined?(ActiveRecord::Base) &&
528
+
529
+ ActiveRecord::Base.connection.disconnect!
530
+
531
+
532
+
533
+ if run_once
534
+
535
+ run_once = false # prevent from firing again
536
+
537
+ end
538
+
539
+
540
+
541
+ old_pid = "#{server.config[:pid]}.oldbin"
542
+
543
+ if File.exist?(old_pid) && server.pid != old_pid
544
+
545
+ begin
546
+
547
+ sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU
548
+
549
+ Process.kill(sig, File.read(old_pid).to_i)
550
+
551
+ rescue Errno::ENOENT, Errno::ESRCH => e
552
+
553
+ logger.error e
554
+
555
+ end
556
+
557
+ end
558
+
559
+ end
560
+
561
+
562
+
563
+ after_fork do |_server, _worker|
564
+
565
+ defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection
566
+
567
+ end
568
+
569
+
570
+
571
+ ```
572
+
573
+
574
+
575
+ ###試したこと
576
+
577
+ **1、`rails db:create RAILS_ENV=production`を実行する**
578
+
579
+
580
+
581
+ 実行した結果は前述の通りです。
582
+
583
+
584
+
585
+ **2、マスターキー**
586
+
587
+
588
+
589
+ "**config直下にmaster.keyがないです**"みたいなエラーが出たこともあって、今は配置済みです。
590
+
591
+ 正直そこも、記事によって書いてあることが違う▼のがよくわからないのですが…
592
+
593
+
594
+
595
+ - アプリ/config/master.key
596
+
597
+ - アプリ/shared/config/master.key
598
+
599
+
600
+
601
+ 最初は`shared/config`にマスターキーを置いていました。
602
+
603
+ 今はアプリ直下の`config`にも配置してあり、本番環境にマスターキーが二つある状態です。
604
+
605
+ (これもエラーの原因になるのでしょうか?)
606
+
607
+
608
+
609
+
610
+
611
+ **3、`production.rb`に追記したコードを削除**
612
+
613
+
614
+
615
+ ```
616
+
617
+ set :linked_files, fetch(:linked_files, []).push("config/master.key")
618
+
619
+ ```
620
+
621
+ この一行を削除しました。
622
+
623
+
624
+
625
+ 参考にした記事で「`deploy.rb`にこれを追記する」ということが書いてあったのですが、私の環境にはそのファイルがなかったため`production.rb`に書いていました。しかし調べると`Capistrano`を導入していく中で生成されるファイルのようだったので「関係ないかな?」と思い削除しました。
626
+
627
+
160
628
 
161
629
 
162
630
 
@@ -176,8 +644,14 @@
176
644
 
177
645
 
178
646
 
179
- **追記**
647
+ ---
180
-
181
-
182
-
648
+
649
+
650
+
183
- 実行たコマンドを書き忘れていました。申し訳ありませんでした
651
+ 同じような質問を繰り返していて大変申し訳ありません。
652
+
653
+ ググるのも下手なら質問も下手……という具合でお恥ずかしい限りです。
654
+
655
+
656
+
657
+ もしこの質問文の中に不要な情報(あるいは不足している情報)等あればご指摘をお願いします。

2

2020/09/22 05:44

投稿

退会済みユーザー
test CHANGED
File without changes
test CHANGED
@@ -5,6 +5,22 @@
5
5
  EC2にRailsアプリの本番環境を構築しています。
6
6
 
7
7
  `unicorn`の起動の際にエラーが出てしまうのですが、ログの英語を翻訳しても意味がよくわからず、原因を探れないでいます。
8
+
9
+
10
+
11
+ ###実行したコマンド
12
+
13
+
14
+
15
+ ```
16
+
17
+ bundle exec unicorn_rails -c config/unicorn.rb -E production -D
18
+
19
+ ```
20
+
21
+
22
+
23
+
8
24
 
9
25
 
10
26
 
@@ -157,3 +173,11 @@
157
173
  - Rails 6
158
174
 
159
175
  - unicorn 5.4.1
176
+
177
+
178
+
179
+ **追記**
180
+
181
+
182
+
183
+ 実行したコマンドを書き忘れていました。申し訳ありませんでした。

1

タイトル

2020/09/20 06:21

投稿

退会済みユーザー
test CHANGED
@@ -1 +1 @@
1
- 【Rails】エラー読み方を教えてください
1
+ 【Rails】ログ意味を教えてください
test CHANGED
File without changes