##前提・困っていること
現在RailsアプリをAWS上にデプロイをしたいのですが、サーバー関連で詰まっています。
EC2上にUnicornとNginxを導入したのですが「502 Bad Gateway」とブラウザに表示されています。
ご教授いただけましたら幸いです。
Nginxの設定ファイル
upstream unicorn { server unix:/sample-app/src/tmp/unicorn.sock; } server { listen 80; server_name ☓☓☓☓☓☓☓; access_log /var/log/nginx/qiita_access.log; error_log /var/log/nginx/qiita_error.log; root /sample-app; client_max_body_size 100m; error_page 404 /404.html; error_page 500 502 503 504 /500.html; try_files $uri/index.html $uri @unicorn; location @unicorn { proxy_set_header X-Real-IP $remote_addr; proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for; proxy_set_header Host $http_host; proxy_pass http://unicorn; } }
Unicornの設定ファイル
worker_processes 4 listen File.expand_path('tmp/unicorn.sock') pid File.expand_path('tmp/unicorn.pid') stderr_path File.expand_path('log/unicorn.log') stdout_path File.expand_path('log/unicorn.log') preload_app true before_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn master intercepting TERM and sending myself QUIT instead' Process.kill 'QUIT', Process.pid end defined?(ActiveRecord::Base) and ActiveRecord::Base.connection.disconnect! end after_fork do |server, worker| Signal.trap 'TERM' do puts 'Unicorn worker intercepting TERM and doing nothing. Wait for master to send QUIT' end defined?(ActiveRecord::Base) and ActiveRecord::Base.establish_connection end
##追記
unicorn.log
I, [2021-03-21T23:52:34.461522 #26347] INFO -- : Refreshing Gem list I, [2021-03-21T23:52:35.256972 #26347] INFO -- : listening on addr=/home/ec2-user/game-bug-app/src/tmp/unicorn.sock fd=15 I, [2021-03-21T23:52:35.294266 #26347] INFO -- : master process ready I, [2021-03-21T23:52:35.329151 #26358] INFO -- : worker=0 ready I, [2021-03-21T23:52:35.330048 #26359] INFO -- : worker=1 ready I, [2021-03-21T23:52:35.334340 #26361] INFO -- : worker=3 ready I, [2021-03-21T23:52:35.335187 #26360] INFO -- : worker=2 ready bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.7.2/bin/unicorn_rails) ArgumentError: Already running on PID:☓☓☓☓☓ (or pid=/home/ec2-user/game-bug-app/src/tmp/unicorn.pid is stale) /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/unicorn-6.0.0/lib/unicorn/http_server.rb:206:in `pid=' /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/unicorn-6.0.0/lib/unicorn/http_server.rb:138:in `start' /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/unicorn-6.0.0/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.7.2/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.7.2/bin/unicorn_rails:23:in `<top (required)>' bundler: failed to load command: unicorn_rails (/home/ec2-user/.rbenv/versions/2.7.2/bin/unicorn_rails) ArgumentError: Already running on PID:☓☓☓☓☓ (or pid=/home/ec2-user/game-bug-app/src/tmp/unicorn.pid is stale) /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/unicorn-6.0.0/lib/unicorn/http_server.rb:206:in `pid=' /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/unicorn-6.0.0/lib/unicorn/http_server.rb:138:in `start' /home/ec2-user/.rbenv/versions/2.7.2/lib/ruby/gems/2.7.0/gems/unicorn-6.0.0/bin/unicorn_rails:209:in `<top (required)>' /home/ec2-user/.rbenv/versions/2.7.2/bin/unicorn_rails:23:in `load' /home/ec2-user/.rbenv/versions/2.7.2/bin/unicorn_rails:23:in `<top (required)>'
回答1件
あなたの回答
tips
プレビュー