【发布时间】:2021-01-11 20:52:31
【问题描述】:
我想使用平台 Ruby 2.7 AL2 version 3.1.1 在 AWS Beanstalk 上托管我的 rails 6.0.3 (ruby 2.7.1) 应用程序。我花了几个小时来解决以下问题,最后,我遇到了一个问题。启动应用程序时出现以下错误:
/var/log/puma/puma.log
[10222] Early termination of worker
[10258] + Gemfile in context: /var/app/current/Gemfile
[10258] Early termination of worker
[31408] - Gracefully shutting down workers...
=== puma startup: 2020-09-25 13:33:02 +0000 ===
=== puma startup: 2020-09-25 13:33:02 +0000 ===
[10501] + Gemfile in context: /var/app/current/Gemfile
[10501] Early termination of worker
[10504] + Gemfile in context: /var/app/current/Gemfile
[10504] Early termination of worker
另一方面,/var/log/web.stdout.log 看起来不错...
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] Puma starting in cluster mode...
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Version 4.3.5 (ruby 2.7.1-p83), codename: Mysterious Traveller
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Min threads: 8, max threads: 32
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Environment: staging
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Process workers: 1
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Phased restart available
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] * Listening on unix:///var/run/puma/my_app.sock
Sep 25 13:33:02 ip-172-31-43-76 web: [10418] Use Ctrl-C to stop
我使用的 puma 版本与官方文档 4.3.5 中指出的相同
我的 config/puma.rb 看起来像:
max_threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }
min_threads_count = ENV.fetch("RAILS_MIN_THREADS") { max_threads_count }
threads min_threads_count, max_threads_count
# Specifies the `port` that Puma will listen on to receive requests; default is 3000.
#
port ENV.fetch("PORT") { 3000 }
# Specifies the `environment` that Puma will run in.
#
environment ENV.fetch("RAILS_ENV") { "development" }
# Specifies the `pidfile` that Puma will use.
pidfile ENV.fetch("PIDFILE") { "tmp/pids/server.pid" }
# Specifies the number of `workers` to boot in clustered mode.
# Workers are forked web server processes. If using threads and workers together,
# the concurrency of the application would be max `threads` * `workers.`
# Workers do not work on JRuby or Windows (both of which do not support
# processes).
#
workers ENV.fetch("WEB_CONCURRENCY") { 2 } # <------ uncomment this line
# Use the `preload_app!` method when specifying a `workers` number.
# This directive tells Puma to first boot the application and load code
# before forking the application. This takes advantage of Copy On Write
# process behavior so workers use less memory.
#
preload_app! # <------ uncomment this line
# Allow Puma to be restarted by the `Rails restart` command.
plugin :tmp_restart
如何修复并正常运行?
【问题讨论】:
-
是的,正如我提到的,我得到了与 AWS 所说的完全相同的 PUMA 版本。
-
暂时我决定大量使用 Beanstalk,直到找到一些可行的解决方案
-
我们遇到了同样的问题,结果证明我们使用的两个中间件 gem 之间存在冲突:NewRelic 和 Sqreen。您能否提供您的 Gemfile 并进行一些测试以禁用您可能正在使用的任何中间件 gem?
-
(这里是 Sqreen 团队)Shawn,是这个吗? github.com/newrelic/newrelic-ruby-agent/issues/461
标签: ruby-on-rails ruby amazon-web-services amazon-elastic-beanstalk puma