0

每次我调用我的 rake 任务时,它都会说:

[2012-07-12 15:50:01] ERROR IOError: An existing connection was forcibly closed by the remote host
        C:/jruby-1.3.1/lib/ruby/1.8/webrick/httpresponse.rb:324:in `_write_data'
        C:/jruby-1.3.1/lib/ruby/1.8/webrick/httpresponse.rb:180:in `send_header'
        C:/jruby-1.3.1/lib/ruby/1.8/webrick/httpresponse.rb:103:in `send_response'
        C:/jruby-1.3.1/lib/ruby/1.8/webrick/httpserver.rb:79:in `run'
        C:/jruby-1.3.1/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
        C:/jruby-1.3.1/lib/ruby/1.8/webrick/server.rb:162:in `start'
[2012-07-12 15:50:29] ERROR IOError: An existing connection was forcibly closed by the remote host
        C:/jruby-1.3.1/lib/ruby/1.8/webrick/httpserver.rb:55:in `run'
        C:/jruby-1.3.1/lib/ruby/1.8/webrick/server.rb:173:in `start_thread'
        C:/jruby-1.3.1/lib/ruby/1.8/webrick/server.rb:162:in `start'

我尝试了不同的选项,认为它可能是对 rake 任务的调用,但显然不是,我也尝试过 Mongrel 和 WEBRick,以防它可能是服务器。我正在使用 Jruby 1.3.1

未执行的任务。

这是我的代码的一部分:

application_controller.rb

 def call_rake(task, options = {})
    options[:rails_env] ||= Rails.env
    args = options.map { |n, v| "#{n.to_s.upcase}='#{v}'" }
    system "C:/jruby-1.3.1/lib/ruby/gems/1.8/gems/rake-0.8.7/lib/rake #{task} #{args.join(' ')} start"
  end

forbidden_file.rake

desc "Process CSV file"
task :process_file => :environment do
  forbidden_file = ForbiddenFile.find(ENV["csv"])
  forbidden_file.upload_file
end

控制器

...
call_rake :process_file, :csv => params[:files]
redirect_to forbidden_files_url
...
4

1 回答 1

0

它现在可以工作了,我刚刚start从命令中删除了这个词。

system "rake #{task} #{args.join(' ')}"
于 2012-08-07T17:44:57.300 回答