3

我正在尝试让调试器 gem 与 shotgun 一起工作,并且要使调试器工作,我需要以“调试开启”启动瘦服务器。

如果我运行:

shotgun -p 1378 -s thin -d -o 0.0.0.0
shotgun -p 1378 -s thin --debug -o 0.0.0.0

我从 $DEBUG ruby​​ 变量设置为 true 开始得到霰弹枪,而不是在打开调试标志的情况下启动瘦服务器。

如果我运行:

shotgun -pp 1378 -s "thin --debug" -o 0.0.0.0

我得到一个错误。当环境设置为开发时,是否有另一种方法来运行它,或者以某种方式告诉瘦在调试器模式下启动?

4

1 回答 1

1

Your -d and --debug options are being interpreted by Shotgun, rather than Thin, and that is what is setting $DEBUG to true.

Thin’s command line flag to turn on debugging is -D or --debug and this sets Thin::Logging.debug to true. You can’t use the thin command line options (sine the command line is being read by shotgun which launches the server), but you can set this variable with some normal Ruby code. One way to do this would be with a shotgun.rb file that requires Thin and changes the setting:

require 'thin'
Thin::Logging.debug = true

(You might want to put this in a begin...rescue...block and rescue the LoadError in case Thin isn’t available.)

The output without this file:

$ shotgun
== Shotgun/Thin on http://127.0.0.1:9393/
>> Thin web server (v1.4.1 codename Chromeo)
>> Maximum connections set to 1024
>> Listening on 127.0.0.1:9393, CTRL+C to stop

and with the file:

$ shotgun
== Shotgun/Thin on http://127.0.0.1:9393/
>> Thin web server (v1.4.1 codename Chromeo)
>> Debugging ON
>> Maximum connections set to 1024
>> Listening on 127.0.0.1:9393, CTRL+C to stop

As far as I can tell, this setting only affects the verbosity of Thin’s logging, and doesn’t have anything to do with the Debugger gem.

于 2012-08-12T22:27:11.387 回答