2016-04-06 32 views
0

Resque'u kullanarak arka planda bir çalışma yapmaya çalışıyorum ve dokümanlar ve takılı kaldığım birkaç öğreticiyi takip ettikten sonra. Resque.log koşarak iş koştu diyor ama gerçekten yoktu. BelirliResque işi işleniyor, ancak hiçbir şey yapmıyor

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 

şey yaptığımı edilmelidir:

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 

Bu günlük geçerli: iş

Şu anda

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

Bu gibi iş arıyorum nedir? peşin

cevap

0

teşekkürler doğru

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 ile bağlantı kurarak bu sorunu çözüldü
İlgili konular