开发者

Ruby mod_passenger process timeout

开发者 https://www.devze.com 2023-04-07 17:02 出处:网络
A few Ruby apps I\'ve worked with han开发者_开发问答g for a long time on slow calls causing processes to backup on the machine eventually requiring a reboot.Is there a quick and easy way in Passenger

A few Ruby apps I've worked with han开发者_开发问答g for a long time on slow calls causing processes to backup on the machine eventually requiring a reboot. Is there a quick and easy way in Passenger to limit a execution time for a single Apache call.

In PHP if a process exceeds the max execution time setting in php.ini the process returns an error to Apache and the server keeps merrily plugging away.


I would take a look at fixing the application. Cutting off requests at the web server level is really more of a band aid and not addressing the core problem - which is request failures, one way or another. If the Ruby app is dependent on another service that is timing out, you can patch the code like this, using the timeout.rb library:

require 'timeout'
status = Timeout::timeout(5) {
  # Something that should be interrupted if it takes too much time...
}

This will let the code "give up" and close out the request gracefully when needed.

0

精彩评论

暂无评论...
验证码 换一张
取 消

关注公众号