【问题标题】:running rake task with rufus-scheduler and sinatra -- it only runs one time instead of the desired interval使用 rufus-scheduler 和 sinatra 运行 rake 任务——它只运行一次而不是所需的时间间隔
【发布时间】:2016-11-16 16:30:41
【问题描述】:

我在我的 app.rb 文件所在的文件夹中有一个 rakefile,我可以成功调用 rakefile 任务一次,但它不会多次运行该任务。它应该每 3 秒运行一次。

require 'sinatra'
require 'rufus/scheduler'
require 'rake'

class MySchedule < Sinatra::Base
  scheduler = Rufus::Scheduler.new
  rake = Rake::Application.new
  Rake.application = rake
  rake.init
  rake.load_rakefile

  scheduler.every '3s' do
    rake[:first_test].invoke
  end
end

MySchedule.new

【问题讨论】:

    标签: ruby sinatra rake rufus-scheduler


    【解决方案1】:

    已解决,可以使用system 'rake first_test'成功调用

    来源:Rake tasks won't run inside of my sinatra app

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2015-08-01
      • 1970-01-01
      • 2011-11-17
      • 1970-01-01
      相关资源
      最近更新 更多