puma服务器冻结

时间:2018-09-03 10:44:26

标签: ruby-on-rails ubuntu puma

我不明白问题是什么。我启动该应用后,该应用可完美运行。一段时间不活动(约5分钟,没有请求)后,当我向其发送请求时,该应用程序停止响应。

puma.rb:

threads_count = ENV.fetch("RAILS_MAX_THREADS") { 5 }.to_i
threads threads_count, threads_count

port        ENV.fetch("PORT") { 3000 }

environment ENV.fetch("RAILS_ENV") { "development" }

plugin :tmp_restart

这就是我这样做的结果:ps aux | grep puma

  

user + 4201 7.8 2.5 1197292 100560吗? Sl 15:41 0:04 puma 3.11.4(tcp://0.0.0.0:3000)[后端]

     

user + 4277 0.0 0.0 15476 1020 pts / 20 S + 15:42 0:00 grep --color = auto美洲豹

ruby -v
  

红宝石2.4.2p198(2017-09-14修订版59899)[x86_64-linux]

rails -v
  

Rails 5.1.6

OS Ubuntu 16.04 LTS

1 个答案:

答案 0 :(得分:0)

这就是您的puma.rb的样子

workers Integer(ENV['WEB_CONCURRENCY'] || 2)
threads_count = Integer(ENV['RAILS_MAX_THREADS'] || 5)
threads threads_count, threads_count

preload_app!

rackup      DefaultRackup
port        ENV['PORT']     || 3000
environment ENV['RACK_ENV'] || 'development'

on_worker_boot do
  ActiveRecord::Base.establish_connection
end