工人 puma 日志提前终止是啥意思,为啥会发生?

Posted

技术标签:

【中文标题】工人 puma 日志提前终止是啥意思,为啥会发生?【英文标题】:What does Early termination of worker puma log mean and why is it happening?工人 puma 日志提前终止是什么意思,为什么会发生? 【发布时间】:2020-08-02 03:16:42 【问题描述】:

对于我的 Elastic Beanstalk 实例,每当我访问它时都会收到 504 状态代码响应。当我跟踪日志时,我在 puma 应用服务器上看到以下日志:

==> /var/log/puma/puma.log <==
[27240] Early termination of worker
[27245] Early termination of worker
[27249] Early termination of worker
[27253] Early termination of worker
[27257] Early termination of worker
[27261] Early termination of worker
[27265] Early termination of worker
[27269] Early termination of worker
[27273] Early termination of worker
[27277] Early termination of worker

Early termination of worker 是什么意思,为什么会这样?此外,日志是否可以指示我在远程环境中面临的超时错误的原因? rails 应用程序和 puma 在我的本地机器(Mac OS Catalina 10.15)上完美运行。但是,在如上所述的远程 Elastic beanstalk 环境中,我收到超时 504 错误,我在日志中看到的唯一内容是上面的 puma 日志。

这是我的 gemfile:

source 'https://rubygems.org'
git_source(:github)  |repo| "https://github.com/#repo.git" 

# Bundle edge Rails instead: gem 'rails', github: 'rails/rails'
gem 'rails', '~> 6.0.1'
# Use mysql as the database for Active Record
gem 'mysql2', '>= 0.4.4'
# Use Puma as the app server
gem 'puma', '~> 4.1'
# Transpile app-like javascript. Read more: https://github.com/rails/webpacker
gem 'webpacker', '~> 4.0'
# Turbolinks makes navigating your web application faster. Read more: https://github.com/turbolinks/turbolinks
gem 'turbolinks', '~> 5'
# Build JSON APIs with ease. Read more: https://github.com/rails/jbuilder
gem 'jbuilder', '~> 2.7'
# Use haml view syntax
gem 'haml-rails'

# the main komponent gem is broken for Rails 6, see:
# https://github.com/komposable/komponent/issues/133
gem 'komponent', github: '0x2C6/komponent'
gem 'elasticsearch', '~> 6.2'
gem 'redis'

# Use Active Model has_secure_password
# gem 'bcrypt', '~> 3.1.7'

# Use Active Storage variant
# gem 'image_processing', '~> 1.2'

# Reduces boot times through caching; required in config/boot.rb
gem 'bootsnap', '>= 1.4.2', require: false

group :development, :test do
  # Call 'byebug' anywhere in the code to stop execution and get a debugger console
  gem 'byebug', platforms: [:mri, :mingw, :x64_mingw]
  gem 'pry-rails'
  gem 'rspec-rails', '~> 3.9'
  gem 'dotenv-rails'
  gem 'awesome_print'
end

group :beta, :production do
  gem 'puma_worker_killer'
end

group :development do
  # Access an interactive console on exception pages or by calling 'console' anywhere in the code.
  gem 'web-console', '>= 3.3.0'
  gem 'listen', '>= 3.0.5', '< 3.2'
  # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
  gem 'spring'
  gem 'spring-watcher-listen', '~> 2.0.0'
  gem 'spring-commands-rspec'
   # Avoid polling for changes (Windows)
  gem 'wdm', '>= 0.1.0', platforms: [:mingw, :mswin, :x64_mingw, :jruby]
end

group :test do
  gem 'webmock'
end

# Windows does not include zoneinfo files, so bundle the tzinfo-data gem
gem 'tzinfo-data', platforms: [:mingw, :mswin, :x64_mingw, :jruby]

【问题讨论】:

***.com/questions/59861277/…的可能重复 【参考方案1】:

我的问题是使用的 puma 的补丁版本不同。

要点是 AWS Elastic Beanstalk 使用的是 puma 4.3.3,而我使用的是 puma 4.3.5

必须将我的 Gemfile 中使用的 puma 的版本修复为与今天的 AWS Elastic Beanstalk 使用的堆栈完全匹配的 4.3.3,以防止出现此错误。

this answer of mine here 中的更多详细信息以了解类似问题。

【讨论】:

【参考方案2】:

好的,所以这需要大量的调试和很多不同的兔子洞。这个问题非常简单。我创建了一个拼写错误并称为GetLitsingsResponse 的类。将课程改回GetListingsResponse后,Puma 在我的远程 AWS Elastic beanstalk 环境中工作得很好。在我的 Mac OS 上本地很奇怪 Puma 没有问题。但在运行 Ruby 2.6 (Puma) 平台的 64 位 Amazon Linux 2018.03 v2.11.4 中,Puma 将无法正常运行。

【讨论】:

不,我必须做的是对我的 ruby​​ 代码进行全面审核/审查——这很困难,因为我引入的更改在 Ruby 代码方面非常大。 那会非常耗时,我不明白为什么我不断收到Early termination of worker。对我来说,审核整个代码不是一种选择,因为它太大了。服务器在开发模式下运行良好,并且当恶魔化为假时。可能必须切换到其他版本的 puma 或寻找其他选项。【参考方案3】:

如果您有 postgres 桌面应用程序,请遵循以下几点

    打开它并打开服务器设置。 打开日志文件 点击菜单栏上的显示。 然后尝试在同一目录中搜索 postmaster.pid。 删除 postmaster.pid。 在应用程序中重新启动您的 puma 服务器。 现在您的 Rails 服务器可以正常工作了。

.

【讨论】:

以上是关于工人 puma 日志提前终止是啥意思,为啥会发生?的主要内容,如果未能解决你的问题,请参考以下文章

Early termination of worker puma log是什么意思,为什么会发生这种情况?

编程中“工人”的概念是啥意思?

为啥我打印素数的代码会提前终止?

hal库中中断服务函数和回调函数是啥意思,他们的的关系是啥呢?

java中多线程地并发运行是啥意思?有啥作用.好处?

这些 ejabberd 信息日志消息是啥意思?