耙任务没有运行

时间:2012-07-12 22:20:04

标签: ruby jruby rake-task

每当我打电话给我的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
...

1 个答案:

答案 0 :(得分:0)

现在正在使用,我刚从命令中删除了start这个词。

system "rake #{task} #{args.join(' ')}"