前提・実現したいこと
既存サービスのコピーに挑戦しようと思い、簡単なActionとビューを用意した後unicornを使用し、デプロイまではうまくいきました。
nginxを導入を試みましたがうまくいきませんでした。
ご教授の程よろしくお願いいたします。
発生している問題・エラーメッセージ
ブラウザのURLバーに「http://xxx.xxx.xxx.xxx:3000」と入力すると見れますが
「http://http://xxx.xxx.xxx」と入力すると
We're sorry, but something went wrong. If you are the application owner check the logs for more information.
と言うエラーメッセージが表示されます。
該当のソースコード
今回のエラーがどこに起因しているかわからないためいくつか思い当たるコード及びログを記載いたします。
unicorn.rb(config/unicorn.rb)
app_path = File.expand_path('../../', __FILE__) worker_processes 1 working_directory app_path pid "#{app_path}/tmp/pids/unicorn.pid" stderr_path "#{app_path}/log/unicorn.stderr.log" stdout_path "#{app_path}/log/unicorn.stdout.log" listen 3000 timeout 60 preload_app true GC.respond_to?(:copy_on_write_friendly=) && GC.copy_on_write_friendly = true check_client_connection false run_once = true before_fork do |server, worker| defined?(ActiveRecord::Base) && ActiveRecord::Base.connection.disconnect! if run_once run_once = false # prevent from firing again end old_pid = "#{server.config[:pid]}.oldbin" if File.exist?(old_pid) && server.pid != old_pid begin sig = (worker.nr + 1) >= server.worker_processes ? :QUIT : :TTOU Process.kill(sig, File.read(old_pid).to_i) rescue Errno::ENOENT, Errno::ESRCH => e logger.error e end end end after_fork do |_server, _worker| defined?(ActiveRecord::Base) && ActiveRecord::Base.establish_connection end
unicorn.stderr.log(気になったところを抜粋)
/var/www/filmarks/config/initializers/devise.rb:5:in `<top (required)>': uninitialized constant Devise (NameError) /home/ec2-user/.rbenv/versions/2.3.1/lib/ruby/gems/2.3.0/gems/devise-4.4.1/lib/devise/rails/routes.rb:500:in `raise_no_secret_key': Devise.secret_key was not set. Please add the following to your Devise initializer: (RuntimeError) Please ensure you restarted your application after installing Devise or setting the key.
rails.conf
upstream app_server { server unix:/tmp/sockets/unicorn.sock; } server { listen 80; server_name <Elastic IP>; root /var/www/<アプリケーション名>/public; location ^~ /assets/ { gzip_static on; expires max; add_header Cache-Control public; root /var/www/<アプリケーション名>/public; } try_files $uri/index.html $uri @unicorn; location @unicorn { proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_redirect off; proxy_pass http://app_server; } error_page 500 502 503 504 /500.html; }
試したこと
①AWS上でbundle install
②unicorn及びnginxの再起動
補足情報(FW/ツールのバージョンなど)
ruby 2.3.1p112
Rails 5.0.6
nginx/1.12.1
回答1件
あなたの回答
tips
プレビュー
バッドをするには、ログインかつ
こちらの条件を満たす必要があります。
2018/02/08 07:59