【发布时间】:2016-09-06 22:58:10
【问题描述】:
我已经安装了一个 Ubuntu Server VM 来托管我的应用程序。
应用程序在我启动后运行良好。一段时间不活动后(大约 5 分钟没有请求),当我向它发送请求时,应用程序停止响应。 服务器日志:
Started GET "/" for 190.104.243.172 at 2016-05-11 13:22:46 +0000
仅此而已。它应该记录:
Started GET "/" for 190.104.243.172 at 2016-05-11 13:22:46 +0000
Processing by DashboardController#root as HTML
Completed 401 Unauthorized in 0ms (ActiveRecord: 0.0ms)
Started GET "/users/sign_in" for 190.104.243.172 at 2016-05-11 13:24:16 +0000
...
就好像它一旦得到请求就没有处理它。
这是我的 puma.rb 配置文件
threads_count = Integer(ENV['MAX_THREADS'] || 16)
threads threads_count, threads_count
workers 1
preload_app!
rackup DefaultRackup
port ENV['PORT'] || 3000
environment ENV['RACK_ENV'] || 'development'
on_worker_boot do
ActiveSupport.on_load(:active_record) do
ActiveRecord::Base.establish_connection
end
end
before_fork do
ActiveRecord::Base.connection_pool.disconnect!
end
例如,如果我将工作人员的数量更改为 2,则 5 分钟后的第一个请求有效。如果我再等 5 分钟,它就会冻结。所以肯定是工人挂着或没有正确装载的东西。
这就是我做ps -aux | grep puma时得到的结果
user 57674 1.2 11.0 1003076 189780 ? Ssl 16:14 0:12 puma 3.4.0 (tcp://0.0.0.0:3000) [be-better-hotels]
user 57771 0.4 14.4 1497004 247484 ? Sl 16:15 0:04 puma: cluster worker 0: 57674 [be-better-hotels]
编辑:向挂起的服务器发出请求大约 30 分钟后,客户端收到 500 Internal Server Error 并且服务器显示此错误消息:
PG::UnableToSend (SSL SYSCALL error: EOF detected):
还有一个非常大的堆栈跟踪。
【问题讨论】:
-
我想我之前也遇到过类似的问题,但不太记得了。你能详细说明你的服务器设置吗? Web 服务器作为负载平衡器/应用程序服务器编号?您也可以运行
ps -ax | grep puma来检查工作进程。我怀疑工作进程在超时后死亡或被某些东西杀死。 -
我已经用
ps -aux | grep puma output进行了编辑,您还需要我展示什么? -
同样的事情发生在我身上。我可以建议在这个问题上悬赏吗?
标签: ruby-on-rails ubuntu puma