有谁知道使用 Thin 同时运行 ruby 调试器和 SSL 的方法?
我在 Rails 3.0.10 中成功使用了 Thin。
我使用 启动它rails server --debugger
,我可以调试我的代码。
最近,我还需要为我的应用程序添加 SSL 支持,我希望能够使用自签名证书在本地对其进行测试。
不幸的是,在使用rails server
.
我可以使用以下方法成功启动具有 SSL 支持的 Thin:
thin start --ssl --ssl-verify --ssl-key-file ssllocal/server.key
--ssl-cert-file ssllocal/server.crt
但是,我还没有找到使用thin start
.
所以看起来我可以选择运行调试器 ( rails server
) 或 SSL ( thin start
),但不能同时运行。
似乎可以rails server
通过修改 rails/script 文件来让 Webrick 运行 SSL(参见此处)。我尝试了这种方法,但没有成功。这是尝试之一:
#!/usr/bin/env ruby
# This command will automatically be run when you run "rails" with Rails 3
# gems installed from the root of your application.
APP_PATH = File.expand_path('../../config/application', __FILE__)
require File.expand_path('../../config/boot', __FILE__)
# THIS IS NEW:
require "rails/commands/server"
require 'rack'
require 'thin'
module Rails
class Server
def default_options
super.merge({
:Port => 3000,
:environment => (ENV['RAILS_ENV'] || "development").dup,
:daemonize => false,
:debugger => false,
:pid => File.expand_path("tmp/pids/server.pid"),
:config => File.expand_path("config.ru"),
:SSLEnable => true
:ssl => true,
"ssl-verify" => true,
"ssl-key-file" => File.expand_path("ssllocal/server.key"),
"ssl-cert-file" => File.expand_path("ssllocal/server.crt")
})
end
end
end
require 'rails/commands'
注意:对于那些可能想知道的人,我在我的根应用程序目录中创建了一个“ssllocal”目录,这就是我存储 ssl 密钥和证书的地方。