内容
下記の記事を参考にしながらデプロイをしています。
参考記事
記事通り最後まで行ったのですが、いざアクセスしてみるとHTTP ERROR 500のエラーが発生してしまいます。
このエラーがサーバー側のエラーであることは調べてわかりました。各種ログを確認してみたのですが、エラーの表記はありませんでした。
また、構文エラーの可能性(特にルーティングエラー)もある、ということで構文の間違いも探していたのですが、結局どこが原因かわかっていません。
production.log
D, [2020-10-19T12:56:23.907729 #27837] DEBUG -- : (0.4ms) BEGIN D, [2020-10-19T12:56:23.908406 #27837] DEBUG -- : ActiveRecord::SchemaMigration Create (0.2ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20200815133259') D, [2020-10-19T12:56:23.910805 #27837] DEBUG -- : (2.3ms) COMMIT I, [2020-10-19T12:56:23.910870 #27837] INFO -- : Migrating to AddColumnsToMicroposts (20200823021534) D, [2020-10-19T12:56:23.936511 #27837] DEBUG -- : (24.3ms) ALTER TABLE `microposts` ADD `latitude` float(24) D, [2020-10-19T12:56:23.959000 #27837] DEBUG -- : (22.2ms) ALTER TABLE `microposts` ADD `longitude` float(24) D, [2020-10-19T12:56:23.959578 #27837] DEBUG -- : (0.3ms) BEGIN D, [2020-10-19T12:56:23.960166 #27837] DEBUG -- : ActiveRecord::SchemaMigration Create (0.2ms) INSERT INTO `schema_migrations` (`version`) VALUES ('20200823021534') D, [2020-10-19T12:56:23.962409 #27837] DEBUG -- : (2.1ms) COMMIT D, [2020-10-19T12:56:23.967167 #27837] DEBUG -- : ActiveRecord::InternalMetadata Load (0.5ms) SELECT `ar_internal_metadata`.* FROM `ar_internal_metadata` WHERE `ar_internal_metadata`.`key` = 'environment' LIMIT 1 D, [2020-10-19T12:56:23.971853 #27837] DEBUG -- : (0.1ms) BEGIN D, [2020-10-19T12:56:23.972858 #27837] DEBUG -- : ActiveRecord::InternalMetadata Create (0.2ms) INSERT INTO `ar_internal_metadata` (`key`, `value`, `created_at`, `updated_at`) VALUES ('environment', 'production', '2020-10-19 12:56:23', '2020-10-19 12:56:23') D, [2020-10-19T12:56:23.975279 #27837] DEBUG -- : (2.2ms) COMMIT D, [2020-10-19T12:56:23.975608 #27837] DEBUG -- : (0.2ms) SELECT RELEASE_LOCK('4373051316486144390') D, [2020-10-19T12:56:52.227115 #27867] DEBUG -- : (0.3ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483 D, [2020-10-19T12:56:52.246138 #27867] DEBUG -- : (0.1ms) SELECT GET_LOCK('4373051316486144390', 0) D, [2020-10-19T12:56:52.251203 #27867] DEBUG -- : (0.3ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC D, [2020-10-19T12:56:52.254256 #27867] DEBUG -- : ActiveRecord::InternalMetadata Load (0.3ms) SELECT `ar_internal_metadata`.* FROM `ar_internal_metadata` WHERE `ar_internal_metadata`.`key` = 'environment' LIMIT 1 D, [2020-10-19T12:56:52.259887 #27867] DEBUG -- : (0.1ms) BEGIN D, [2020-10-19T12:56:52.260889 #27867] DEBUG -- : (0.1ms) COMMIT D, [2020-10-19T12:56:52.261137 #27867] DEBUG -- : (0.1ms) SELECT RELEASE_LOCK('4373051316486144390') D, [2020-10-19T12:57:01.602922 #27897] DEBUG -- : (0.3ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483 D, [2020-10-19T12:57:01.622732 #27897] DEBUG -- : (0.2ms) SELECT GET_LOCK('4373051316486144390', 0) D, [2020-10-19T12:57:01.627839 #27897] DEBUG -- : (0.2ms) SELECT `schema_migrations`.`version` FROM `schema_migrations` ORDER BY `schema_migrations`.`version` ASC D, [2020-10-19T12:57:01.630922 #27897] DEBUG -- : ActiveRecord::InternalMetadata Load (0.3ms) SELECT `ar_internal_metadata`.* FROM `ar_internal_metadata` WHERE `ar_internal_metadata`.`key` = 'environment' LIMIT 1 D, [2020-10-19T12:57:01.635683 #27897] DEBUG -- : (0.1ms) BEGIN D, [2020-10-19T12:57:01.636701 #27897] DEBUG -- : (0.1ms) COMMIT D, [2020-10-19T12:57:01.636967 #27897] DEBUG -- : (0.2ms) SELECT RELEASE_LOCK('4373051316486144390') D, [2020-10-19T12:59:11.654627 #27983] DEBUG -- : (0.3ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483 D, [2020-10-19T13:04:44.304480 #28090] DEBUG -- : (0.3ms) SET NAMES utf8, @@SESSION.sql_mode = CONCAT(CONCAT(@@sql_mode, ',STRICT_ALL_TABLES'), ',NO_AUTO_VALUE_ON_ZERO'), @@SESSION.sql_auto_is_null = 0, @@SESSION.wait_timeout = 2147483
Nginxのログ
2020/10/19 12:59:20 [notice] 27991#0: signal process started 2020/10/19 13:04:57 [notice] 28098#0: signal process started
Unicornログ
ユニコーンのログがみれましたので更新しています。
E, [2020-10-21T23:05:01.651670 #28093] ERROR -- : app error: Missing `secret_key_base` for 'production' environment, set this string with `rails credentials:edit` (ArgumentError) E, [2020-10-21T23:05:01.651773 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3/lib/rails/application.rb:585:in `validate_secret_key_base' E, [2020-10-21T23:05:01.651793 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3/lib/rails/application.rb:432:in `secret_key_base' E, [2020-10-21T23:05:01.651857 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3/lib/rails/application.rb:253:in `env_config' E, [2020-10-21T23:05:01.651870 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3/lib/rails/engine.rb:712:in `build_request' E, [2020-10-21T23:05:01.651881 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3/lib/rails/application.rb:608:in `build_request' E, [2020-10-21T23:05:01.651891 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/railties-5.2.4.3/lib/rails/engine.rb:523:in `call' E, [2020-10-21T23:05:01.651901 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:606:in `process_client' E, [2020-10-21T23:05:01.651911 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:701:in `worker_loop' E, [2020-10-21T23:05:01.651922 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:549:in `spawn_missing_workers' E, [2020-10-21T23:05:01.651932 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicorn-5.4.1/lib/unicorn/http_server.rb:142:in `start' E, [2020-10-21T23:05:01.651943 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/lib/ruby/gems/2.7.0/gems/unicorn-5.4.1/bin/unicorn_rails:209:in `<top (required)>' E, [2020-10-21T23:05:01.651964 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/bin/unicorn_rails:23:in `load' E, [2020-10-21T23:05:01.651975 #28093] ERROR -- : /home/taishi/.rbenv/versions/2.7.1/bin/unicorn_rails:23:in `<main>'
ps auxwww | grep unicornの結果
taishi 28090 0.0 10.6 601460 107084 ? Sl 13:04 0:01 unicorn_rails master -c /var/www/rails/portfolio/config/unicorn.conf.rb -D -E production taishi 28093 0.0 9.6 601460 96896 ? Sl 13:04 0:00 unicorn_rails worker[0] -c /var/www/rails/portfolio/config/unicorn.conf.rb -D -E production taishi 28094 0.0 9.6 601460 96896 ? Sl 13:04 0:00 unicorn_rails worker[1] -c /var/www/rails/portfolio/config/unicorn.conf.rb -D -E production taishi 30079 0.0 0.0 119436 968 pts/2 S+ 23:09 0:00 grep --color=auto unicorn
toppages/index(トップページ)
<html> <head> <meta charset="UTF-8"> <link rel= "stylesheet" href = "../assets/stylesheets/applocation.css" > </head> <body class="main_body"> <div class = "main_container"> <h1 class ="title">らぐふれ!</h1> <p class="sub_title">〜全国のラグビーイベントを探すサイト〜</p> <div class="top_button"><a href="signup" class="btn-cross">新規登録</a></div> </div> </body> </html>
toppages_controller.rb
class ToppagesController < ApplicationController def index if logged_in? redirect_to microposts_path end end end
routes.rb
Rails.application.routes.draw do root to: 'toppages#index' get 'login', to: 'sessions#new' post 'login', to: 'sessions#create' delete 'logout', to: 'sessions#destroy' get 'signup', to: 'users#new' get '/microposts/:id/comment', to: 'microposts#comment', as: 'comment' get '/microposts/:id/map', to: 'microposts#map', as: 'map' delete '/microposts/:id/comment', to: 'comments#destroy' get '/users/:id/join_ivent', to: 'users#join_ivent', as:'join_ivent' get '/users/:id/user_liking', to: 'users#user_liking', as:'user_liking' resources :users do member do get :followings get :followers get :likings get :joinings end collection do get :search end end resources :microposts do member do get :joined get :liked resources :comments, only: [:create, :destroy] end collection do get :search end end resources :relationships, only: [:create, :destroy] resources :joins, only: [:create, :destroy] resources :likes, only: [:create, :destroy] resources :comments, only: [:create, :destroy] end
回答1件
あなたの回答
tips
プレビュー