如何关闭ruby瘦服务器HTTP keep-alive?

时间:2013-03-03 16:04:05

标签: ruby thin keep-alive

目前,我正在以编程方式在我的程序中生成HTTP服务器。

srv =   Thin::Server.start('0.0.0.0', 3000, app)

我无法弄清楚我应该在哪里看到更改保持活动时间设置。因为瘦服务器不会立即死亡,所以在调试和开发应用程序时困扰我。我会打开保持活着的生产,但我仍然希望控制持续时间。

2 个答案:

答案 0 :(得分:1)

如果您不希望等待待处理的待处理请求,请致电stop!

if RAKE_ENV=='production'
  srv.stop
else
  srv.stop!
end

Thin source

答案 1 :(得分:0)

    #       Thin::Server.stop! doesn't work immediately if there's live keep-alive connection.
    #       SIGINT doesn't work.
    #       Only SIGKILL works.
    #       But `abort` is a lot quicker way.
    #       Overridden to abort.

    trap("INT") { puts " Force quit by raising intentional crash!" ;abort() }