Search code examples
rubythinkeep-alive

How to turn off ruby thin server HTTP keep-alive?


Currently I am spawning HTTP server within my program programmatically.

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

And I can't figure out where should I see to change keep-alive time setting. Because thin server do not die immediately, it bothers me when debugging and developing app. I will turn on the keep-alive for production, but still I want to control the duration.


Solution

  •     #       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() }