【问题标题】:Message/logging from Thin来自 Thin 的消息/日志记录
【发布时间】:2012-02-08 11:53:54
【问题描述】:

如何阻止 Rack Thin 返回以下类型的初始消息?

>> 瘦 Web 服务器(v1.3.1 代号 Triple Espresso)
>> 最大连接数设置为 1024
>> istening on 0.0.0.0:3000, CTRL+C to stop

我是这样使用它的:

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)

【问题讨论】:

    标签: ruby logging rack thin


    【解决方案1】:

    看起来最初的消息来自Thin。根据他们的 Github Issue #31 Disabling all logging,您可以在其余代码之前添加 Thin::Logging.silent = true 以使初始消息静音。

    但是,这也会使来自瘦适配器的所有其他消息静音。看一眼the source 说这些其他消息也将被静音:

    • 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

    希望这会有所帮助!

    【讨论】:

    • 很高兴你发现它有用!
    【解决方案2】:

    那些消息不是来自机架,它们来自瘦:https://github.com/macournoyer/thin/blob/master/lib/thin/server.rb#L150 您可以根据此设置日志记录首选项:https://github.com/macournoyer/thin/blob/master/lib/thin/logging.rb Thin::Logging.silent = true,但您真的要全部静音吗?也许将其定向到日志文件而不是标准输出?

    【讨论】:

      猜你喜欢
      • 2015-05-03
      • 1970-01-01
      • 2011-07-11
      • 2015-05-21
      • 2016-02-20
      • 2012-09-24
      • 1970-01-01
      • 1970-01-01
      • 2012-05-24
      相关资源
      最近更新 更多