Ruby on rails Heroku计划程序任务未按预期运行

Ruby on rails Heroku计划程序任务未按预期运行,ruby-on-rails,heroku,scheduled-tasks,rake,rake-task,Ruby On Rails,Heroku,Scheduled Tasks,Rake,Rake Task,我正在使用Heroku的调度器插件,以预定的时间间隔在我的应用程序中运行作业,就像传统服务器环境中的cron一样。这些任务相当琐碎,因为它们只是让一个sidekiq工作人员排队。但是,如下图所示,:update\u job\u posts由于某些原因未能在UTC时间4:30运行 我不能以这种方式组合这两个作业,还是它们需要单独运行 如果我使用heroku run运行任务,它将通过heroku-run用于执行作业,因此您可以确信,如果它与heroku-run一起工作,它将从调度程序工作 $ her

我正在使用Heroku的调度器插件,以预定的时间间隔在我的应用程序中运行作业,就像传统服务器环境中的cron一样。这些任务相当琐碎,因为它们只是让一个sidekiq工作人员排队。但是,如下图所示,
:update\u job\u posts
由于某些原因未能在UTC时间4:30运行

我不能以这种方式组合这两个作业,还是它们需要单独运行

如果我使用heroku run运行任务,它将通过
heroku-run
用于执行作业,因此您可以确信,如果它与heroku-run一起工作,它将从调度程序工作

$ heroku run rake scheduler:update_job_posts
Running rake scheduler:update_job_posts on ⬢ agile-temple-76502... up, run.6604 (Free)
Updating Job feed...
I, [2018-06-06T04:40:50.341411 #4]  INFO -- : [ActiveJob] Enqueued JobFeedImportJob (Job ID: e3b9a0ed-aacb-45af-84f9-ef02acfeb85e) to Sidekiq(default)
I, [2018-06-06T04:40:50.344400 #4]  INFO -- : [ActiveJob] Enqueued RemoteFeedImportJob (Job ID: b965853d-adb3-46ee-b48d-f19306ce9d2a) to Sidekiq(default)
done.
此外,
heroku日志--tail
显示正在运行的其他任务:

heroku[scheduler.5009]: Starting process with command `bundle exec rake scheduler:update_news_articles`
heroku[scheduler.5009]: State changed from starting to up
app[scheduler.5009]: Updating News feed...
app[scheduler.5009]: I, [2018-06-06T04:31:05.636594 #4]  INFO -- : [ActiveJob] Enqueued NewsFeedImportJob (Job ID: d672b0c5-598b-4eb7-81b6-1a0d2d8a5891) to Sidekiq(default)
app[scheduler.5009]: done.
app[worker.1]: 4 TID-tfdlg NewsFeedImportJob JID-d999a576b3193a404b3d8fdd INFO: start
app[worker.1]: I, [2018-06-06T04:31:05.636769 #4]  INFO -- : [ActiveJob] [NewsFeedImportJob] [d672b0c5-598b-4eb7-81b6-1a0d2d8a5891] Performing NewsFeedImportJob from Sidekiq(default)
heroku[scheduler.5009]: Process exited with status 0
heroku[scheduler.5009]: State changed from up to complete
调度程序。rake

namespace :scheduler do
  desc "Enqueue sidekiq job, fetches events, and creates a record for new entries"
  task :update_event_feed => :environment do
    puts "Updating Event feed..."
    EventFeedImportJob.perform_later
    puts "done."
  end

  desc "Enqueue sidekiq job, fetches job posts, and creates a record for new entries"
  task :update_job_posts => :environment do
    puts "Updating Job feed..."
    JobFeedImportJob.perform_later
    RemoteFeedImportJob.perform_later
    puts "done."
  end

  desc "Enqueue sidekiq job, fetches news articles, and creates a record for new entries"
  task :update_news_articles => :environment do
    puts "Updating News feed..."
    NewsFeedImportJob.perform_later
    puts "done."
  end
end

Heroku调度员在文档上说

Scheduler是一个免费的附加组件,不保证作业将在其预定时间执行,或者根本不执行:

在极少数情况下,作业可能会被跳过。

在极少数情况下,作业可能会运行两次。

我在某些情况下实现了这一点,我注意到在几天过去后,它不能与后台进程正常工作,然后再次阅读他们的文档并找出原因

现在我已经实现了,并且工作正常

我希望这会有帮助。

Heroku调度员在文档上说

Scheduler是一个免费的附加组件,不保证作业将在其预定时间执行,或者根本不执行:

在极少数情况下,作业可能会被跳过。

在极少数情况下,作业可能会运行两次。

我在某些情况下实现了这一点,我注意到在几天过去后,它不能与后台进程正常工作,然后再次阅读他们的文档并找出原因

现在我已经实现了,并且工作正常


我希望这会有所帮助。

奇怪的是,这两个作业运行了,而另一个没有,日志中没有错误。自周三以来,所有的工作都按时完成。您是否只需要在作业中使用“sidekiq调度程序”,并在
config/sidekiq.yml
中设置
:schedule
?听起来太容易了!!你有没有发现sidekiq调度程序出现了问题,或者它运行了所有的作业?是的,当然这很容易&它准确地运行了所有的作业。我想我会有机会进行切换。
update\u news\u articles
作业今晚无法运行(根据我的原始消息,它们计划在每天的同一时间运行);也没有此故障的错误日志。我惊讶地发现Heroku调度程序的执行如此不一致。我从未能运行的作业中错过了14篇新文章。奇怪的是,这两个作业运行了,而另一个没有,日志中没有错误。自周三以来,所有的工作都按时完成。您是否只需要在作业中使用“sidekiq调度程序”,并在
config/sidekiq.yml
中设置
:schedule
?听起来太容易了!!你有没有发现sidekiq调度程序出现了问题,或者它运行了所有的作业?是的,当然这很容易&它准确地运行了所有的作业。我想我会有机会进行切换。
update\u news\u articles
作业今晚无法运行(根据我的原始消息,它们计划在每天的同一时间运行);也没有此故障的错误日志。我惊讶地发现Heroku调度程序的执行如此不一致。我错过了14篇没有运行的新文章。