require 'clockwork'
include Clockwork
handler do |job|
  puts "Running #{job}"
end
every(10.seconds, 'frequent.job')
every(3.minutes, 'less.frequent.job')
every(1.hour, 'hourly.job')
every(1.day, 'midnight.job', :at => '00:00')require_relative "../config/environment"
require_relative "../config/boot"
require 'clockwork'
include Clockwork
handler do |job|
 puts "running the scheduled job #{job}."
end
every(30.seconds, 'test job execution'){Module::Class.new.method_to_call}As this application is to be deployed over heroku, we need to have 2 dynos, one for the rails and another for the extra task. We define this through Procfile file present at rails root with the following contents:
web    bundle exec unicorn -p $PORT -c ./config/unicorn.rb
clock  bundle exec clockwork app/lib/clock.rb 
 
1 comment:
Use command on terminal to start Clockworld (rails)
bundle exec clockwork lib/clock.rb
Post a Comment