2017-04-14 87 views
0

我有一個時間表,它是在resque.rake定義是這樣的:Resque schedueler加載作業而不是入隊

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 

的schedele 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的服務器,軌道S,通過

bundle exec rake resque:work QUEUE='*' --trace 

加載工人

束EXEC耙環境resque:調度我得到以下輸出

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但它看起來是沒有得到enqued(我忽略了迄今的命名空間警告)

調度顯示在resque-scheduler web ui中,並且每當我通過web界面按鈕手動設置它時,作業就會成功執行。任何ide爲什麼它不正確加載?

Queue now button used to set of jobs

+0

按下「確認」鍵後,我看到這些信息可以幫助我 – Ievgen

回答

0

所以在很多的嘗試後,周圍的最後,我發現resque調度沒有拿起我的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