【问题标题】:AWS Beanstalk - Early termination of workerAWS Beanstalk - 工作人员提前终止
【发布时间】: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

如何修复并正常运行?

【问题讨论】:

标签: ruby-on-rails ruby amazon-web-services amazon-elastic-beanstalk puma


【解决方案1】:

请检查以下内容:

  • 在本地运行生产。这可以向您显示其他错误(例如 Zeitwerk 错误)
  • 检查供应商目录下的权限,gem 文件所在的位置。我们的依赖项之一没有其他人的读取权限并导致错误。您可以通过将脚本添加到 .ebextensions 来更改此设置
  • 也请查看此链接:AWS elastic beanstalk is not getting the environment variables

在我们的例子中,我们中了大奖。以上都是...

【讨论】:

    猜你喜欢
    • 2021-08-22
    • 2023-03-09
    • 2023-03-25
    • 2012-08-21
    • 1970-01-01
    • 2021-01-28
    • 2018-01-31
    • 2021-09-29
    • 1970-01-01
    相关资源
    最近更新 更多