7
我有我想从一个命令行Ruby程序启动西纳特拉:: Base的web服务,所以我有这样的:如何静静地启动Sinatra + Thin?
# command line program file
require 'mymodule/server'
puts "Running on 0.0.0.0:4567, debugging to STDOUT..."
MyModule::Server.run! bind: '0.0.0.0', port: 4567, environment: :production
可正常工作,但它抛出:
$ myscript
Running on 0.0.0.0:4567, debugging to STDOUT...
== Sinatra/1.3.1 has taken the stage on 4567 for production with backup from Thin
>> Thin web server (v1.3.1 codename Triple Espresso)
>> Maximum connections set to 1024
>> Listening on 0.0.0.0:4567, CTRL+C to stop
127.0.0.1 - - [23/Dec/2011 18:44:55] "POST /images HTTP/1.1" 200 360 0.0133
...
我希望它保持沉默,并让我输出我想要的。例如,如果我启动它不是进程化我只想看到命令行程序的一些消息和日志输出,是这样的:
$ myscript
Running on 0.0.0.0:4567, debugging to STDOUT...
127.0.0.1 - - [23/Dec/2011 18:44:55] "POST /images HTTP/1.1" 200 360 0.0133
...
也想静静地关闭它,隐藏:
== Sinatra has ended his set (crowd applauds)
最后一个问题是,这是从应用程序代码(本例中为ruby脚本)开始使用瘦身技术的最佳选择吗?
禁用':logging'不会为我工作。 – Nakilon 2013-02-17 20:42:08
如果使用SinatraBase,则必须在类声明中执行此操作... http://www.sinatrarb.com/intro.html#Sinatra::Base%20-%20Middleware,%20Libraries,%20and%20Modular%20Apps – GroovyCakes 2013-02-20 21:47:35
你也可以尝试选项的启用/禁用样式设置 – GroovyCakes 2013-02-20 21:49:17