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