【问题标题】:Rails application deployed on Elastic Beanstalk with Puma fails - 502 Bad Gateway使用 Puma 部署在 Elastic Beanstalk 上的 Rails 应用程序失败 - 502 Bad Gateway
【发布时间】:2018-12-30 09:24:57
【问题描述】:

当我部署新版本时,我遇到了这个错误。我试图遵循关于堆栈溢出的几个指令,但没有帮助。当我部署时,健康状态首先是成功的,然后当我访问该网站时,它会变为降级。 在网站上我得到错误

502 网关错误
nginx/1.12.1

这是来自 nginx/error.log 的图片

错误

2018/07/22 23:11:55 [error] 3038#0: *5502 connect() to unix:///var/run/puma/my_app.sock failed (111: Connection refused) while connecting to upstream, client: 68.228.233.169, server: _, request: "GET /robots.txt HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/robots.txt", host: "borroupenv.us-east-1.elasticbeanstalk.com"
2018/07/22 23:11:55 [error] 3038#0: *5498 connect() to unix:///var/run/puma/my_app.sock failed (111: Connection refused) while connecting to upstream, client: 68.228.233.169, server: _, request: "GET /favicon.ico HTTP/1.1", upstream: "http://unix:///var/run/puma/my_app.sock:/favicon.ico", host: "borroupenv.us-east-1.elasticbeanstalk.com", referrer: "http://borroupenv.us-east-1.elasticbeanstalk.com/"

这是来自 puma.rb

 threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
 threads threads_count, threads_count
 port        ENV.fetch("PORT") { 3000 }
 environment ENV.fetch("RAILS_ENV") { "development" }
 bind "unix:///var/run/puma/my_app.sock"
 pidfile "/var/run/puma/my_app.sock"
 plugin :tmp_restart

这是来自 config/environments/production.rb

Rails.application.configure do
  config.cache_classes = true
  config.eager_load = true
  config.consider_all_requests_local       = false
  config.action_controller.perform_caching = true
  config.read_encrypted_secrets = true
  config.public_file_server.enabled = ENV['RAILS_SERVE_STATIC_FILES'].present?
  config.assets.js_compressor = :uglifier
  config.assets.compile = false
  config.log_level = :debug
  config.log_tags = [ :request_id ]
  config.action_mailer.perform_caching = false
  config.action_mailer.delivery_method = :smtp
  config.action_mailer.smtp_settings = {
     address: 'smtp.mailgun.org',
     port: 587,
     domain: 'borroup.com',
     enable_starttls_auto: true,
     authentication: 'plain',
     user_name: '',
     password: ''
   } 
   config.i18n.fallbacks = true
   config.active_support.deprecation = :notify
   config.log_formatter = ::Logger::Formatter.new
     if ENV["RAILS_LOG_TO_STDOUT"].present?
     logger           = 
      ActiveSupport::Logger.new(STDOUT)
     logger.formatter = config.log_formatter
     config.logger    = 
     ActiveSupport::TaggedLogging.new(logger)
     end
  config.active_record.dump_schema_after_migration = 
 false
end

【问题讨论】:

    标签: ruby-on-rails node.js amazon-web-services nginx amazon-ec2


    【解决方案1】:

    我能够重新打开网站并解决 Nging 错误。

    这是我在 Mac 上的结果。在 Mac 上压缩时,它使用弹性 beanstalk 不支持的 Darwin 二进制 zip 文件。我通过下载 Keka 并使用该工具进行压缩来做到这一点。

    【讨论】:

      猜你喜欢
      • 2015-05-18
      • 2021-06-22
      • 2016-12-20
      • 2016-02-27
      • 2020-04-22
      • 2020-10-01
      • 2014-05-12
      • 2021-03-07
      • 2015-08-02
      相关资源
      最近更新 更多