2016-04-06 10 views
0

私はresqueを使ってバックグラウンドでジョブを実行しようとしています。ドキュメントといくつかのチュートリアルの後に私は立ち往生しています。 resque.logを実行すると、ジョブが実行されたと表示されますが、実際には実行されませんでした。私は現在、これは仕事ですResqueジョブは処理されましたが、何もしません

Resque.enqueue(CsvImporterJob, params[:file].path, @organization.id) 

のような仕事を呼び出しています

class CsvImporterJob < ActiveJob::Base 
    @queue = :import 

    def self.perform(file, organization_id) 
    CSV.foreach(file, :headers => true) do |row| 
     if row 
     user = row.to_hash 
     email = user["email"] 
     case user["role"].downcase 
     when "admin" 
      role_id = Role.admin 
     else 
      role_id = Role.user 
     end 
     ActivateHelper.send_activation_token(email, organization_id, role_id) 
     end 
    end 
    end 
end 

これはログです:

D, [2016-04-06T11:02:59.854604 #6548] DEBUG -- : resque-1.25.2: Waiting for * 
D, [2016-04-06T11:03:04.856115 #6548] DEBUG -- : Checking import 
D, [2016-04-06T11:03:04.856388 #6548] DEBUG -- : Found job on import 
I, [2016-04-06T11:03:04.856441 #6548] INFO -- : got: (Job{import} | CsvImporterJob | ["/var/folders/92/87zkvh_53mb3721x4025vmsr0000gn/T/RackMultipart20160406-6422-1t7akw1.csv", 6]) 
D, [2016-04-06T11:03:04.856771 #6548] DEBUG -- : resque-1.25.2: Processing import since 1459954984 [CsvImporterJob] 
I, [2016-04-06T11:03:04.856811 #6548] INFO -- : Running before_fork hooks with [(Job{import} | CsvImporterJob | ["/var/folders/92/87zkvh_53mb3721x4025vmsr0000gn/T/RackMultipart20160406-6422-1t7akw1.csv", 6])] 
D, [2016-04-06T11:03:04.858903 #6548] DEBUG -- : resque-1.25.2: Forked 6608 at 1459954984 
I, [2016-04-06T11:03:04.859985 #6608] INFO -- : Running after_fork hooks with [(Job{import} | CsvImporterJob | ["/var/folders/92/87zkvh_53mb3721x4025vmsr0000gn/T/RackMultipart20160406-6422-1t7akw1.csv", 6])] 
I, [2016-04-06T11:03:04.865640 #6608] INFO -- : done: (Job{import} | CsvImporterJob | ["/var/folders/92/87zkvh_53mb3721x4025vmsr0000gn/T/RackMultipart20160406-6422-1t7akw1.csv", 6]) 
D, [2016-04-06T11:03:04.869546 #6548] DEBUG -- : Checking import 
D, [2016-04-06T11:03:04.869914 #6548] DEBUG -- : Sleeping for 5.0 seconds 
D, [2016-04-06T11:03:04.869947 #6548] DEBUG -- : resque-1.25.2: Waiting for * 
D, [2016-04-06T11:03:09.871048 #6548] DEBUG -- : Checking import 
D, [2016-04-06T11:03:09.871237 #6548] DEBUG -- : Sleeping for 5.0 seconds 
D, [2016-04-06T11:03:09.871459 #6548] DEBUG -- : resque-1.25.2: Waiting for * 
D, [2016-04-06T11:03:14.872187 #6548] DEBUG -- : Checking import 
D, [2016-04-06T11:03:14.872390 #6548] DEBUG -- : Sleeping for 5.0 seconds 

私がやるべき具体的な何か?事前に感謝

答えて

0

は正しく

require 'resque/tasks' 
require 'resque/scheduler/tasks' 

task "resque:setup" => :environment do 
    ENV['QUEUE'] = '*' 

    Resque.redis = 'localhost:6379' unless Rails.env == 'production' 

    Resque.before_fork = Proc.new do |job| 
    ActiveRecord::Base.connection.disconnect! 
    end 
    Resque.after_fork = Proc.new do |job| 
    ActiveRecord::Base.establish_connection 
    end 
end 
のRedisとの接続を設定することにより、この問題を解決します
関連する問題