Frage

I'm trying to learn how to use the gem clockwork. I'm just trying to test on my Mac and putting a line onto the development log. I have it set at 3 minutes just for testing.

I have the following in lib/clock.rb :

require 'clockwork'
module Clockwork
  handler do |job|
    puts "Running #{job} =================================="
  end
Clockwork.every(3.minutes, 'dailyjob')
end

Then I have lib/tasks/dailyjob.rb

class DailyJob
  def perform
    Rails.logger.info "Daily Job ========================================="
  end
end

I then start Clockworks via the console $ clockwork clock.rb. It starts up and every 3 minutes the console says:

Running dailyjob ==================================
I, [2014-03-04T11:03:32.084240 #66442]  INFO -- : Triggering 'dailyjob'

But, nothing shows up in the development.log file.

Thanks for the help!

War es hilfreich?

Lösung

Per docs, Clockwork will only write to STDOUT unless you configure it otherwise:

By default Clockwork logs to STDOUT. In case you prefer your own logger implementation you have to specify the logger configuration option. See example below.

Example from the docs is this:

module Clockwork
  configure do |config|
    config[:sleep_timeout] = 5
    config[:logger] = Logger.new(log_file_path)
    config[:tz] = 'EST'
    config[:max_threads] = 15
    config[:thread] = true
  end
end
Lizenziert unter: CC-BY-SA mit Zuschreibung
Nicht verbunden mit StackOverflow
scroll top