Skip to content

Instantly share code, notes, and snippets.

@captproton
Created November 14, 2011 21:09
Show Gist options
  • Select an option

  • Save captproton/1365176 to your computer and use it in GitHub Desktop.

Select an option

Save captproton/1365176 to your computer and use it in GitHub Desktop.
run workers on time
require 'clockwork'
include Clockwork
# Ruby 1.9.2 does not add the current directory in the LOAD_PATH, so we need to be more direct
require File.expand_path('../config/boot', __FILE__) #instead of: require 'config/boot'
require File.expand_path('../config/environment', __FILE__) # instead of: require 'config/environment'
handler do |job|
puts "Running #{job}"
end
# testing to see if clock is working
every(15.seconds, 'greeting.job') { puts "hi there!" }
# cues up delayed_job of caching techmeme.com headlines, to be executed as soon as not busy.
every(15.seconds, 'techmeme.refresh') { Headline.delay.for_yesterday_and_today_and_top_feed }
every(30.seconds, 'markepoint_quote_collection.refresh') { MarketPoint.delay.update_quotes }
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment