我在端口6379上的Linux Mint 17上运行了redis-server。我使用lib/clock.rb
中的以下clockwork文件来运行使用sidekiq的cron任务:
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
sidekiq任务定义如下:
class FeedUpdater
include Sidekiq::Worker
def perform()
puts 'Doing hard work'
end
end
但是,当我运行bundle exec clockwork lib/clock.rb
时,我得到以下输出:
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 ---------'
我希望输出包含任务(简单的print语句)。
My Gemfile看起来像这样:
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'
感谢任何帮助。
答案 0 :(得分:1)
您需要在单独的shell中启动sidekiq worker。如果还没有(设置db或命名空间)
,最好为sidekiq配置redis