前提・実現したいこと
unicornの起動をしたい。
####環境
MacOS Catalina 10.15.7
ruby on rails 6.0.3.4
ruby 2.6.5
発生している問題・エラーメッセージ
Railsを起動しようとしても「masterは起動失敗します。」と出る。
$ bundle exec unicorn_rails -c config/unicorn.rb -E production -D master failed to start, check stderr log for details $ RAILS_SERVE_STATIC_FILES=1 unicorn_rails -c config/unicorn.rb -E production -D master failed to start, check stderr log for details
###ファイル等
ruby:unicorn.rb
1#サーバ上でのアプリケーションコードが設置されているディレクトリを変数に入れておく 2app_path = File.expand_path('../../', __FILE__) 3 4#アプリケーションサーバの性能を決定する 5worker_processes 1 6 7#アプリケーションの設置されているディレクトリを指定 8working_directory app_path 9 10#Unicornの起動に必要なファイルの設置場所を指定 11pid "#{app_path}/tmp/pids/unicorn.pid" 12 13#ポート番号を指定 14listen 3000 15 16#エラーのログを記録するファイルを指定 17stderr_path "#{app_path}/log/unicorn.stderr.log" 18 19#通常のログを記録するファイルを指定 20stdout_path "#{app_path}/log/unicorn.stdout.log" 21 22#Railsアプリケーションの応答を待つ上限時間を設定 23timeout 60 24 25#以下は応用的な設定なので説明は割愛 26 27preload_app true 28GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true 29 30check_client_connection false 31 32run_once = true 33 34before_fork do |server, worker| 35 defined?(ActiveRecord::Base) && 36 ActiveRecord::Base.connection.disconnect! 37 38 if run_once 39 run_once = false # prevent from firing again 40 end 41 42 old_pid = "#{server.config[:pid]}.oldbin" 43 if File.exist?(old_pid) && server.pid != old_pid 44 begin 45 sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU 46 Process.kill(sig, File.read(old_pid).to_i) 47 rescue Errno::ENOENT, Errno::ESRCH => e 48 logger.error e 49 end 50 end 51end 52 53after_fork do |_server, _worker| 54 defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection 55end
試したこと
エラーメッセージを表示しようとコマンド入力
$ less log/unicorn.stderr.log Zeitwerk::NameError: expected file /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.3/app/mailers/devise/mailer.rb to def ine constant Devise::Mailer, but didn't /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader/callbacks.rb:17:in `on_file_autoloaded' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:28:in `block in require' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:27:in `tap' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:27:in `require' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:392:in `const_get' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:392:in `block (2 levels) in eager_load' /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:742:in `block in ls' 省略 I, [2020-11-13T11:09:42.167780 #3142] INFO -- : Refreshing Gem list /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader/callbacks.rb:17:in `on_file_autoloaded': expecte d file /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.3/app/mailers/devise/mailer.rb to define constant Devise::Mailer, but didn't (Zeitwerk::NameError) from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:28:in `block in require' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:27:in `tap' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:27:in `require' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:392:in `const_get' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:392:in `block (2 levels) in eager_load' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:742:in `block in ls' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:734:in `foreach' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:734:in `ls' 省略 I, [2020-11-13T11:18:48.450711 #3285] INFO -- : Refreshing Gem list /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader/callbacks.rb:17:in `on_file_autoloaded': expected file /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/devise-4.7.3/app/mailers/devise/mailer.rb to define constant Devise::Mailer, but didn't (Zeitwerk::NameError) from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:28:in `block in require' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:27:in `tap' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/kernel.rb:27:in `require' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:392:in `const_get' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:392:in `block (2 levels) in eager_load' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:742:in `block in ls' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:734:in `foreach' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:734:in `ls' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:387:in `block in eager_load' from /home/ec2-user/.rbenv/versions/2.6.5/lib/ruby/gems/2.6.0/gems/zeitwerk-2.4.0/lib/zeitwerk/loader.rb:376:in `synchronize' 省略
mailer.rb
if defined?(ActionMailer) class Devise::Mailer < Devise.parent_mailer.constantize include Devise::Mailers::Helpers def confirmation_instructions(record, token, opts = {}) @token = token devise_mail(record, :confirmation_instructions, opts) end def reset_password_instructions(record, token, opts = {}) @token = token devise_mail(record, :reset_password_instructions, opts) end def unlock_instructions(record, token, opts = {}) @token = token devise_mail(record, :unlock_instructions, opts) end def email_changed(record, opts = {}) devise_mail(record, :email_changed, opts) end def password_change(record, opts = {}) devise_mail(record, :password_change, opts) end end end
Devise::Mailerが定義されないため止まっていると書いてありますが、定義するにはどうすればいいんでしょうか・・・。
お力添えいただける方がいましたらよろしくお願い致します!
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。