延迟工作有问题

时间:2013-07-17 02:33:58

标签: ruby-on-rails delayed-job

所以,我使用延迟的工作,例如,邮件传递:

def send_password_reset
    begin
      password_reset_token= SecureRandom.urlsafe_base64
    end while User.exists?(:password_reset_token => password_reset_token)

  self.password_reset_token= password_reset_token
  self.password_link_sent_at=Time.now.utc
  self.save!(:validate=>false)
  UserMailer.delay.password_reset(self)
  end

然后是DB:

 SQL (1.0ms)  INSERT INTO "delayed_jobs" ("attempts", "created_at", "failed_at", "handler", "last_error", "locked_at", "locked_by", "priority", "queue", "run_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10, $11) RETURNING "id"  [["attempts", 0], ["created_at", Wed, 17 Jul 2013 02:18:14 UTC +00:00], ["failed_at", nil], ["handler", "--- !ruby/object:Delayed::PerformableMailer\nobject: !ruby/class 'UserMailer'\nmethod_name: :password_reset\nargs:\n- !ruby/ActiveRecord:User\n  attributes:\n    id: '114'\n    email: testmail@mail.ru\n    password_digest: $2a$10$XLYdoO2vSyVuGvcUi05r3eF3of7OvtxWIP.WfJPgD3yju/SE8qiXW\n    created_at: '2013-06-15 21:04:42.425284'\n    updated_at: 2013-07-17 02:18:14.086686000 Z\n    guest: f\n    auth_token: oDZA3QN5aznIaK0MRiOqsA\n    password_reset_token: 4bVLGOkzEww3bbvs_tAd7g\n    password_link_sent_at: 2013-07-17 02:18:14.083686000 Z\n    confirmed: t\n    confirmation_token: CnSI6tUUYGyCCVTrVnPIow\n    confirmation_link_sent_at: '2013-06-15 21:04:36.849965'\n"], ["last_error", nil], ["locked_at", nil], ["locked_by", nil], ["priority", 0], ["queue", nil], ["run_at", Wed, 17 Jul 2013 02:18:14 UTC +00:00], ["updated_at", Wed, 17 Jul 2013 02:18:14 UTC +00:00]]

当我从控制台拨打上一份工作时:

<Delayed::Backend::ActiveRecord::Job id: 127, priority: 0, attempts: 0, handler: "--- !ruby/object:Delayed::PerformableMailer\nobject:...", last_error: nil, run_at: "2013-07-17 02:18:14", locked_at: nil, failed_at: nil, locked_by: nil, queue: nil, created_at: "2013-07-17 02:18:14", updated_at: "2013-07-17 02:18:14">

但实际上并没有这样做:

[Worker(host:HP-PC pid:13476)] Starting job worker

运行rake jobs:work之后,它只是空的,没有关于处理作业的信息。

例如,我打电话给:

User.delay.test_method

是:

  def self.test_method

    nil.what?

  end

没有错误。延迟的工作甚至没有开始处理它。

0 个答案:

没有答案