在收集TERM并发送QUIT之后Heroku上的独angular兽退出超时

我正在接收运行独angular兽和sidekiq的Heroku应用程序的R12退出超时错误。 这些错误每天发生1-2次,每当我部署。 我知道我需要将来自Heroku的关机信号转换为独angular兽才能正确响应,但是我认为我已经在下面的独angular兽configuration中这样做了:

worker_processes 3 timeout 30 preload_app true before_fork do |server, worker| Signal.trap 'TERM' do puts "Unicorn master intercepting TERM and sending myself QUIT instead. My PID is #{Process.pid}" Process.kill 'QUIT', Process.pid end if defined?(ActiveRecord::Base) ActiveRecord::Base.connection.disconnect! Rails.logger.info('Disconnected from ActiveRecord') end end after_fork do |server, worker| Signal.trap 'TERM' do puts "Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT. My PID is #{Process.pid}" end if defined?(ActiveRecord::Base) ActiveRecord::Base.establish_connection Rails.logger.info('Connected to ActiveRecord') end Sidekiq.configure_client do |config| config.redis = { :size => 1 } end end 

我周围的错误日志如下所示:

 Stopping all processes with SIGTERM Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT. My PID is 7 Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT. My PID is 11 Unicorn worker intercepting TERM and doing nothing. Wait for master to sent QUIT. My PID is 15 Unicorn master intercepting TERM and sending myself QUIT instead. My PID is 2 Started GET "/manage" reaped #<Process::Status: pid 11 exit 0> worker=1 reaped #<Process::Status: pid 7 exit 0> worker=0 reaped #<Process::Status: pid 15 exit 0> worker=2 master complete Error R12 (Exit timeout) -> At least one process failed to exit within 10 seconds of SIGTERM Stopping remaining processes with SIGKILL Process exited with status 137 

看起来,所有的subprocess都是在超时之前成功获得的。 主人还活着吗? 另外,如果日志中显示,路由器是否应该在关机期间向网页发送网页请求?

FWIW,我正在使用Heroku的零停机部署插件( https://devcenter.heroku.com/articles/labs-preboot/ )。

我认为你的自定义信号处理是什么导致超时在这里。

编辑:我越来越downvoted不同意Heroku的文档,我想解决这个问题。

configuration你的Unicorn应用程序来捕捉和吞下TERM信号是最有可能导致应用程序挂起而不能正确closures的原因。

Heroku似乎认为,将TERM信号捕捉并转换为QUIT信号是将硬关机转换为正常关机的正确行为。

但是,这样做似乎在某些情况下会导致无法closures的风险 – 这个bug的根源。 使用独angular兽的用户应该考虑证据,并根据第一原则作出自己的决定,而不仅仅是文档。