【问题标题】:My ROR+Nginx+Passenger+AWS is sending 502 bad gateway我的 ROR+Nginx+Passenger+AWS 正在发送 502 bad gateway
【发布时间】:2017-07-11 22:06:32
【问题描述】:

我正在使用 ROR+Nginx+passenger 和 Amazon Web 服务开发 android 服务。

服务器运行良好,但昨天服务器突然宕机了。

我试图解决这个问题,但我不能。

这是我的问题。

首先,EC2 实例的 log/production.log 不写入任何日志。 我可以在我的 android 应用程序日志中收到 502 bad gateway 错误消息。

其次,包括http、https在内的所有请求都由502 badgateway响应。

第三,我的 AWS 负载均衡器正在记录 50X 错误。

我猜这个问题是关于ELB的,但我不知道如何解决。

我有 ssl 证书,但我只有一个 EC2 实例。

任何帮助将不胜感激。

已编辑

2017-02-22 00:22:30.9139 25313/7f222067b700 age/Cor/Con/CheckoutSession.cpp:269 ]: [Client 1-356202] Returning HTTP 503 due to: Request queue full (configured max. size: 100)
[ 2017-02-22 00:24:00.3704 25313/7f221ee09700 age/Cor/App/Implementation.cpp:304 ]: Could not spawn process for application /home/ec2-user/popcake: An error occurred while starting up the preloader: it did not write a startup response in time.
  Error ID: 10045ede
  Error details saved to: /tmp/passenger-error-JS1Bnt.html
  Message from application: An error occurred while starting up the 

preloader: it did not write a startup response in time. Please read <a href="https://github.com/phusion/passenger/wiki/Debugging-application-startup-problems">this article</a> for more information about this problem.<br>
    <h2>Raw process output:</h2>
    (empty)

    [ 2017-02-22 00:24:00.4527 25313/7f222067b700 age/Cor/Con/CheckoutSession.cpp:285 ]: [Client 1-353433] Cannot checkout session because a spawning error occurred. The identifier of the error is 10045ede. Please see earlier logs for details about the error.
[ 2017-02-22 00:30:29.0872 25313/7f222067b700 age/Cor/CoreMain.cpp:532 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ 2017-02-22 00:30:29.1173 25313/7f2227bfc840 age/Cor/CoreMain.cpp:901 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ 2017-02-22 00:30:29.1174 25313/7f221fe7a700 Ser/Server.h:817 ]: [ApiServer] Freed 0 spare client objects
[ 2017-02-22 00:30:29.1174 25313/7f221fe7a700 Ser/Server.h:464 ]: [ApiServer] Shutdown finished

[ 2017-02-22 00:30:29.2400 25318/7f77237e2700 age/Ust/UstRouterMain.cpp:422 ]: Signal received. Gracefully shutting down... (send signal 2 more time(s) to force shutdown)
[ 2017-02-22 00:30:29.2741 25318/7f772a775840 age/Ust/UstRouterMain.cpp:492 ]: Received command to shutdown gracefully. Waiting until all clients have disconnected...
[ 2017-02-22 00:30:29.3043 25318/7f77237e2700 Ser/Server.h:464 ]: [UstRouter] Shutdown finished
[ 2017-02-22 00:30:29.3042 25318/7f7722fe1700 Ser/Server.h:817 ]: [UstRouterApiServer] Freed 0 spare client objects
[ 2017-02-22 00:30:29.3048 25318/7f7722fe1700 Ser/Server.h:464 ]: [UstRouterApiServer] Shutdown finished
[ 2017-02-22 00:30:29.3720 25318/7f772a775840 age/Ust/UstRouterMain.cpp:523 ]: Passenger UstRouter shutdown finished

[ 2017-02-22 00:30:29.4023 25313/7f222067b700 age/Cor/CoreMain.cpp:532 ]: Signal received. Gracefully shutting down... (send signal 1 more time(s) to force shutdown)

【问题讨论】:

  • 检查 Nginx 错误日志文件以查看错误。
  • @rails_id 如何访问 Nginx 错误文件?
  • @JeongmyeongLee 您可以访问此路径:/var/log/nginx/ 并找到 error 文件。同tail -f /var/log/nginx/error.log
  • 我编辑了一些特色错误。几乎所有的日志都和上面一样。
  • 我在 /opt/nginx/logs/error.log 找到了这个日志。这取决于 nginx 的版本或其他东西。

标签: ruby-on-rails amazon-web-services amazon-ec2


【解决方案1】:

如果您看到已添加的日志显示“请求队列已满”,则基本上您有一些长时间运行的 api,因为队列已满后会抛出 50x。

现在重启 nginx 可能会解决这个问题,但您需要查看 api 的响应时间,看看哪些执行缓慢并修复它们,否则这将是一个反复出现的问题,您必须每天重启 nginx。

【讨论】:

    猜你喜欢
    • 2021-03-04
    • 2021-01-25
    • 2023-03-20
    • 2018-04-23
    • 2021-02-24
    • 1970-01-01
    • 2022-08-16
    • 2020-05-15
    • 2020-05-09
    相关资源
    最近更新 更多