Resque workers failing in production

I have a model which contains the following:

  def fetch_austlii
    Resque.enqueue(FetchAustliiJob, self.id) # Queue the job for later.
  end

This dispatches the app/workers/fetch_austlii_job.rb file:

class FetchAustliiJob

  @queue = :fetch_queue

  def self.perform(profile_id)
    @profile = Profile.find(profile_id)
    AustliiResource.fetch(@profile.name).each do |resource|
      @profile.austlii_resources.create!(resource.attributes) if @profile.austlii_resources.find_all_by_url(resource.url).empty?
    end
  end

end

In development (OS X, Ruby 1.9.2, Rails3, Postgres, Redis-server, Foreman) it works fine. The job retrieves information from the internet just like it should. However, in production (Ubuntu, Ruby 1.9.2, Passenger) it fails with:

Class
FetchAustliiJob
Arguments
2
Exception
NoMethodError
Error
undefined method `austlii_resources' for #<Profile:0x00000002fab6b0>

Answers


Make sure you're running the workers in the correct environment (production vs development) on the server.

If you haven't already tried, you may want to create a config/setup_load_paths.rb to load the RVM environment (source: RVM Passenger docs):

if ENV['MY_RUBY_HOME'] && ENV['MY_RUBY_HOME'].include?('rvm')
  begin
    rvm_path     = File.dirname(File.dirname(ENV['MY_RUBY_HOME']))
    rvm_lib_path = File.join(rvm_path, 'lib')
    $LOAD_PATH.unshift rvm_lib_path
    require 'rvm'
    RVM.use_from_path! File.dirname(File.dirname(__FILE__))
  rescue LoadError
    # RVM is unavailable at this point.
    raise "RVM ruby lib is currently unavailable."
  end
end

ENV['BUNDLE_GEMFILE'] = File.expand_path('../Gemfile', File.dirname(__FILE__))
require 'bundler/setup'

Need Your Help

Find files which have certain attributes

linux shell command-line find

I'd like to find all files in the current directory recursively with the following attributes:

How to escape single quotes in Sybase

sql sybase

I come from MySQL and the below query doesn't work in Sybase. How should I escape single quotes?

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.