Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Message/logging from Thin

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)
like image 978
sawa Avatar asked Jan 12 '12 06:01

sawa


2 Answers

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!

like image 108
ligfx Avatar answered Sep 26 '22 11:09

ligfx


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?

like image 26
sunkencity Avatar answered Sep 25 '22 11:09

sunkencity