ruby-on-rails – 具有SSL支持和ruby-debug的瘦身
有没有人知道使用Thin同时运行ruby调试器和SSL的方法?
我一直在使用Rails 3.0.10成功使用Thin. 我使用rails server –debugger启动它,我可以调试我的代码. 最近,我还需要为我的应用程序添加SSL支持,并且我希望能够使用自签名证书在本地测试它. 不幸的是,在使用rails服务器时,我还没有找到一种方法来启动Thin with SSL支持. 我可以使用以下方法成功启动Thin with SSL支持: thin start --ssl --ssl-verify --ssl-key-file ssllocal/server.key --ssl-cert-file ssllocal/server.crt 但是,我还没有找到使用瘦启动激活调试器的方法. 所以我似乎可以选择运行调试器(rails服务器)或SSL(瘦启动),但不能同时运行. 通过修改rails / script文件(see here),似乎可以让Webrick使用rails服务器运行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密钥和证书的地方. 解决方法
您可以尝试在开发环境中自己要求调试器.
在你的Gemfile中: if RUBY_VERSION =~ /^1.9/ gem "ruby-debug19",:group => :development else gem "ruby-debug",:group => :development end 在config / environments / development.rb的config块中: require 'ruby-debug' Debugger.start 这允许您将调试器语句放在代码中的任何位置. (编辑:李大同) 【声明】本站内容均来自网络,其相关言论仅代表作者个人观点,不代表本站立场。若无意侵犯到您的权利,请及时与联系站长删除相关内容! |