Where should I define my registrar in my rails application

I installed Resque in my rails application and everything works fine. The question I have is where the registrar installation should go. Should it be in the initializer or in the rake task? It works when configured in both. The reason why I ask, I saw how it was used as in the examples on the network.

I think that probably it should be in the initializer, since it is best to put the settings in the initializers.

config / initializers / resque.rb

logfile = File.open(File.join(Rails.root, 'log', 'resque.log'), 'a')
logfile.sync = true
Resque.logger = ActiveSupport::Logger.new(logfile)
Resque.logger.level = Logger::INFO

Then I write using the Resque.logger syntax in the task and the rake tasks.

eg:

Resque.logger.info "Resque task started!"

Thank you very much in advance.

EDIT
Then I'll stick with the initializer.

+4
source share
2

, , .

+3

: , (config/initializers/resquer.rb) rake (lib/tasks/resque.rake), , , .

class OneJob
  def self.perform
    Resque.logger = Logger.new("#{Rails.root}/log/resque.log")
    Resque.logger.level = Logger::DEBUG   

    Resque.logger.info 'Job starts'
    ...
  end
en
0

All Articles