0

我正在尝试执行以下操作:

  1. 每 15 分钟运行一个 Worker 和其中的一个方法
  2. 在数据库表 bdrd_job_queue 中有一个上次运行时的作业日志。

我做了什么:

我的 backgroundRB.yml 文件中每 15 分钟有一个时间表

方法调用有persistent_job.finish!调用,但是不起作用,因为persistent_job对象为nil。

如何确保它已登录数据库,但仍从 backgroundRB.yml 自动安排?

4

1 回答 1

0

我终于能够做到了。

解决方法是安排一个任务,将其排队到数据库中,安排为立即运行。

在你的工人...

class NotificationWorker < BackgrounDRb::MetaWorker
  set_worker_name :notification_worker

  def create(args = nil)
  end

  def queue_notify_changes(args = nil)
    BdrbJobQueue.insert_job(:worker_name => 'notification_worker',
                            :worker_method => 'notify_new_changes_DAEMON',
                            :args => 'hello_world',
                            :scheduled_at => Time.now.utc,
                            :job_key => 'email_changes_notification_task')
  end
  def notify_new_changes_DAEMON
     #Do Incredibly cool stuff here
  end

在配置文件 backgroundrb.yml

--- 
:backgroundrb: 
  :ip: 0.0.0.0
  :port: 11006
  :environment: production
  :log: foreground
  :debug_log: true
  :persistent_disabled: false
  :persistent_delay: 10

:schedules:
  :notification_worker:
    :queue_notify_changes:
      :trigger_args: 0 0 0 * * *
于 2009-11-06T18:00:00.660 回答