Resque 调度程序加载作业但不排队
Resque schedueler loading jobs but not enqueing
我有一个时间表,它在 resque.rake 中定义如下:
require 'resque/tasks'
require 'resque/scheduler/tasks'
task 'resque:setup' => :environment
namespace :resque do
task :setup do
require 'resque'
Resque.redis = 'localhost:6379'
end
task :setup_schedule => :setup do
require 'resque-scheduler'
ENV['RAILS_ENV'] = Rails.env
Resque.schedule = YAML.load_file('config/tweet_schedule.yml')
require 'tweet_sender.rb'
end
task :scheduler => :setup_schedule
end
时间表tweet_schedule.yml
tweet_sender:
cron: "57 7 * * *"
class: "TweetSender"
queue: tweets_queue
args: tweet_id
rails_env: development
description: "This job sends daily tweets from the content db"
每当我 运行(和 redis-server、rails 时,通过
加载工人
bundle exec rake resque:work QUEUE='*' --trace
)
bundle exec rake environment resque:scheduler 我得到以下输出
resque-scheduler: [INFO] 2017-04-14T09:14:49+02:00: Starting
resque-scheduler: [INFO] 2017-04-14T09:14:49+02:00: Loading Schedule
resque-scheduler: [INFO] 2017-04-14T09:14:49+02:00: Scheduling tweet_sender
resque-scheduler: [INFO] 2017-04-14T09:14:49+02:00: Schedules Loaded
Passing 'info' command to redis as is; administrative commands cannot be effectively namespaced and should be called on the redis connection directly; passthrough has been deprecated and will be removed in redis-namespace 2.0 (at sucesfully/home/jan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/resque-1.27.2/lib/resque/data_store.rb:60:in `method_missing')
Passing 'script' command to redis as is; administrative commands cannot be effectively namespaced and should be called on the redis connection directly; passthrough has been deprecated and will be removed in redis-namespace 2.0 (at /home/jan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/resque-1.27.2/lib/resque/data_store.rb:60:in `method_missing')
所以我假设它正在加载我的 schedusucesfullyle 但看起来它没有被排队(到目前为止我已经忽略了命名空间警告)
计划显示在 resque-scheduler 网络 ui 中,每当我通过网络界面按钮手动设置它时,作业都会成功执行。 ide 为什么它不能正确加载?
最后,经过大量尝试,我发现 resque scheduler 没有获取我的 cron 定义。
将 5* cron 更改为 6*cron 后
5* cron cron: "57 7 * * *"
5* cron cron: "15 57 7 * * *"
作业现在每小时安排一次。我还没有弄清楚每天如何安排工作,因为标准的 cron 语法似乎不起作用
minute (0-59),
| hour (0-23),
| | day of the month (1-31),
| | | month of the year (1-12),
| | | | day of the week (0-6 with 0=Sunday).
| | | | | command
0 2 * * 0,4
我有一个时间表,它在 resque.rake 中定义如下:
require 'resque/tasks'
require 'resque/scheduler/tasks'
task 'resque:setup' => :environment
namespace :resque do
task :setup do
require 'resque'
Resque.redis = 'localhost:6379'
end
task :setup_schedule => :setup do
require 'resque-scheduler'
ENV['RAILS_ENV'] = Rails.env
Resque.schedule = YAML.load_file('config/tweet_schedule.yml')
require 'tweet_sender.rb'
end
task :scheduler => :setup_schedule
end
时间表tweet_schedule.yml
tweet_sender:
cron: "57 7 * * *"
class: "TweetSender"
queue: tweets_queue
args: tweet_id
rails_env: development
description: "This job sends daily tweets from the content db"
每当我 运行(和 redis-server、rails 时,通过
加载工人bundle exec rake resque:work QUEUE='*' --trace
)
bundle exec rake environment resque:scheduler 我得到以下输出
resque-scheduler: [INFO] 2017-04-14T09:14:49+02:00: Starting
resque-scheduler: [INFO] 2017-04-14T09:14:49+02:00: Loading Schedule
resque-scheduler: [INFO] 2017-04-14T09:14:49+02:00: Scheduling tweet_sender
resque-scheduler: [INFO] 2017-04-14T09:14:49+02:00: Schedules Loaded
Passing 'info' command to redis as is; administrative commands cannot be effectively namespaced and should be called on the redis connection directly; passthrough has been deprecated and will be removed in redis-namespace 2.0 (at sucesfully/home/jan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/resque-1.27.2/lib/resque/data_store.rb:60:in `method_missing')
Passing 'script' command to redis as is; administrative commands cannot be effectively namespaced and should be called on the redis connection directly; passthrough has been deprecated and will be removed in redis-namespace 2.0 (at /home/jan/.rbenv/versions/2.2.3/lib/ruby/gems/2.2.0/gems/resque-1.27.2/lib/resque/data_store.rb:60:in `method_missing')
所以我假设它正在加载我的 schedusucesfullyle 但看起来它没有被排队(到目前为止我已经忽略了命名空间警告)
计划显示在 resque-scheduler 网络 ui 中,每当我通过网络界面按钮手动设置它时,作业都会成功执行。 ide 为什么它不能正确加载?
最后,经过大量尝试,我发现 resque scheduler 没有获取我的 cron 定义。
将 5* cron 更改为 6*cron 后
5* cron cron: "57 7 * * *"
5* cron cron: "15 57 7 * * *"
作业现在每小时安排一次。我还没有弄清楚每天如何安排工作,因为标准的 cron 语法似乎不起作用
minute (0-59),
| hour (0-23),
| | day of the month (1-31),
| | | month of the year (1-12),
| | | | day of the week (0-6 with 0=Sunday).
| | | | | command
0 2 * * 0,4