I have redis-server running on Linux Mint 17 on port 6379. I am using the following clockwork file in lib/clock.rb
to run a cron task using sidekiq:
require 'clockwork'
require './config/boot'
require './config/environment'
module Clockwork
handler do |job|
puts "Running #{job}"
end
every(5.seconds, 'COLLECT FEEDS ---------') do
FeedUpdater.perform_async()
end
end
The sidekiq task is defined as follows:
class FeedUpdater
include Sidekiq::Worker
def perform()
puts 'Doing hard work'
end
end
However, when I run bundle exec clockwork lib/clock.rb
I get the following output:
I, [2014-11-15T14:00:43.888627 #27822] INFO -- : Starting clock for 1 events: [ COLLECT FEEDS --------- ]
I, [2014-11-15T14:00:43.888700 #27822] INFO -- : Triggering 'COLLECT FEEDS ---------'
2014-11-15T19:00:43Z 27822 TID-2ipeg INFO: Sidekiq client with redis options {}
I, [2014-11-15T14:00:48.891139 #27822] INFO -- : Triggering 'COLLECT FEEDS ---------'
I, [2014-11-15T14:00:53.893416 #27822] INFO -- : Triggering 'COLLECT FEEDS ---------'
I expect the output to include the task (simple print statement).
My Gemfile looks like so:
source 'https://rubygems.org'
gem 'rails', '4.1.1'
gem 'pg'
gem 'sass-rails', '~> 4.0.3'
gem 'uglifier', '>= 1.3.0'
gem 'coffee-rails', '~> 4.0.0'
gem 'jquery-rails'
gem 'turbolinks'
gem 'jbuilder', '~> 2.0'
gem 'sdoc', '~> 0.4.0', group: :doc
gem 'spring', group: :development
gem 'feedjira'
gem 'sidekiq', '~> 3.1.4'
gem 'clockwork', '~> 0.7.7'
Any help is appreciated.
You need to start sidekiq worker in separate shell. Also it's better to configure redis for sidekiq if not yet (set db or namespace)
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.