Message/logging from Thin
Asked Answered
D

2

7

How can I stop Rack Thin from returning initial messages of the following type?

>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> istening on 0.0.0.0:3000, CTRL+C to stop

I am using it like this:

Rack::Handler::Thin.run(Rack::Builder.new do
    map("/resource/"){run(Rack::File.new("/"))}
    map("/") do
        run(->env{
            h = Rack::Utils.parse_nested_query(env["QUERY_STRING"])
            [200, {},[routine_to_generate_dynamic_content(h)]]
        })
    end
end, Port: 3000)
Darreldarrell answered 12/1, 2012 at 6:15 Comment(0)
T
2

Those messages does not come from rack, they come from thin: https://github.com/macournoyer/thin/blob/master/lib/thin/server.rb#L150 You can set the logging preferences according to this: https://github.com/macournoyer/thin/blob/master/lib/thin/logging.rb Thin::Logging.silent = true, but do you really want to silence all? Maybe direct it to a log file instead of stdout?

Torrez answered 12/1, 2012 at 7:0 Comment(0)
I
4

Looks like the initial messages are coming from Thin. As per their Github Issue #31, Disabling all logging, you can add Thin::Logging.silent = true before the rest of the code to silence the initial messages.

However, this will also silence all other messages from the Thin adapter. A glance at the source says these other messages will also be silenced:

  • Waiting for n connection(s) to finish, can take up to n sec, CTRL+C to stop now
  • Stopping ...
  • !! Ruby 1.8.5 is not secure please install cgi_multipart_eof_fix:
       gem install cgi_multipart_eof_fix

Hope this helps!

Idolah answered 12/1, 2012 at 7:1 Comment(1)
I'm glad you found it useful!Idolah
T
2

Those messages does not come from rack, they come from thin: https://github.com/macournoyer/thin/blob/master/lib/thin/server.rb#L150 You can set the logging preferences according to this: https://github.com/macournoyer/thin/blob/master/lib/thin/logging.rb Thin::Logging.silent = true, but do you really want to silence all? Maybe direct it to a log file instead of stdout?

Torrez answered 12/1, 2012 at 7:0 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.