来自 Thin 的消息/日志记录
如何阻止 Rack Thin 返回以下类型的初始消息?
>>瘦 Web 服务器(v1.3.1 代号 Triple Espresso)
>>>最大连接数设置为 1024
>>>监听 0.0.0.0:3000,CTRL+C 停止
我这样使用它:
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)
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)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
看起来最初的消息来自 Thin。根据他们的 Github Issue #31,禁用所有日志记录,您可以添加
Thin ::Logging.silent = true
在代码的其余部分之前,以静默初始消息。但是,这也会使来自瘦适配器的所有其他消息静默。浏览来源说这些其他消息也将被静音:
等待 n 个连接完成,最多可能需要 n 秒,CTRL+C 立即停止
正在停止...
!! Ruby 1.8.5 不安全,请安装 cgi_multipart_eof_fix:
gem install cgi_multipart_eof_fix
希望这有帮助!
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!
这些消息不是来自机架,而是来自 Thin: 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,但是您真的想让所有内容都静音吗?也许将其定向到日志文件而不是标准输出?
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?