【发布时间】:2012-01-06 04:57:48
【问题描述】:
有人知道使用 Thin 同时运行 ruby 调试器和 SSL 的方法吗?
我已经在 Rails 3.0.10 中成功使用 Thin。
我使用rails server --debugger 启动它,我可以调试我的代码。
最近,我还需要为我的应用程序添加 SSL 支持,我希望能够使用自签名证书在本地对其进行测试。
不幸的是,在使用 rails server 时,我还没有找到一种方法来启动 Thin 并支持 SSL。
我可以使用以下方法成功启动具有 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/script 文件 (see here) 让 Webrick 使用 rails server 运行 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 密钥和证书的地方。
【问题讨论】:
标签: ruby-on-rails ssl thin ruby-debug