使用 Puma 部署在 Elastic Beanstalk 上的 Rails 应用程序失败 - 每个请求都出现 502 错误 [英] Rails application deployed on Elastic Beanstalk with Puma fails - 502 errors on every request

查看:22
本文介绍了使用 Puma 部署在 Elastic Beanstalk 上的 Rails 应用程序失败 - 每个请求都出现 502 错误的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我刚刚向 Elastic Beanstalk 部署了一个 Rails 应用程序,每个请求都给我一个 502 错误.

I just deployed a Rails app to Elastic Beanstalk, and every request is giving me a 502 error.

这里是/var/logs/nginx/error.log的内容

Here's the contents of /var/logs/nginx/error.log

2015/05/20 16:24:25 [warn] 1535#0: conflicting server name "localhost" on 0.0.0.0:80, ignored
2015/05/20 16:27:12 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:27:17 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:27:19 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:27:22 [crit] 1537#0: *16 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.44.210, server: _, request: "GET /datapoint?tickers=AAPL&datapoints=Ratings HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/datapoint?tickers=AAPL&datapoints=Ratings", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:27:27 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:27:32 [crit] 1537#0: *20 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:28:53 [crit] 1537#0: *52 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "GET /datapoint?tickers=AAPL&datapoints=Ratings HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/datapoint?tickers=AAPL&datapoints=Ratings", host: "securities-api-prod.elasticbeanstalk.com"
2015/05/20 16:30:47 [crit] 1537#0: *69 connect() to unix:///var/run/puma/my_app.sock failed (2: No such file or directory) while connecting to upstream, client: 172.31.51.94, server: _, request: "POST /get HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/get", host: "securities-api-prod.elasticbeanstalk.com"

我认为 puma 正在运行 -

I think puma is running -

[ec2-user@ip-172-31-44-135 nginx]$ ps aux | grep puma
root     23299  1.0  0.2  53008  1428 ?        Ss   16:38   0:00 su -s /bin/bash -c puma -C /opt/elasticbeanstalk/support/conf/pumaconf.rb webapp
webapp   23314  0.0  2.4  75764 14604 ?        Rsl  16:38   0:00 /opt/rubies/ruby-2.1.4/bin/ruby /opt/rubies/ruby-2.1.4/bin/puma -C /opt/elasticbeanstalk/support/conf/pumaconf.rb
ec2-user 23317  0.0  0.1 110284   844 pts/0    S+   16:38   0:00 grep puma

pumaconf.rb

pumaconf.rb

directory '/var/app/current'
threads 8, 32
workers %x(grep -c processor /proc/cpuinfo)
bind 'unix:///var/run/puma/my_app.sock'
stdout_redirect '/var/log/puma/puma.log', '/var/log/puma/puma.log', true
daemonize false

有人知道这是怎么回事吗?

Anyone know what's going on?

推荐答案

我遇到了同样的错误,将这两行添加到 config/puma.rb 修复了问题:

I faced the same error and adding these two lines to config/puma.rb fixed the problem:

bind "unix:///var/run/puma/my_app.sock"
pidfile "/var/run/puma/my_app.sock"

在这一步之后,我在添加 ENV 值时遇到了另一个错误,这是非常直接的.

After this step I faced another error to add ENV values, which is very straight forward.

希望这会有所帮助.

这篇关于使用 Puma 部署在 Elastic Beanstalk 上的 Rails 应用程序失败 - 每个请求都出现 502 错误的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆