7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?

More than 5 years have passed since last update.

Rails gem: delayed_jobのデバッグ

Last updated at Posted at 2015-06-09

delayed_job で遅延実行するジョブのデバッグはどうやるの?

発端

ログに以下のようにでてworkerは走っているようだが期待する結果が得られないときどこを確認するのか。

Job Delayed::PerformableMethod (id=24) RUNNING

確認方法

delayed_jobの設定を変更する。
config/initializer/delayed_job_config.rb等:

Delayed::Worker.destroy_failed_jobs = false  # 失敗したジョブをキューから消さない設定
Delayed::Worker.logger = Logger.new(File.join(Rails.root, 'log', 'delayed_job.log'))  # ログファイル出力

railsを実行。

ワーカーを実行。
$ script/delayed_job start

railsを操作するなどしてジョブを投入。

ログを見て、失敗を確認したら、

$ cd rails_dir
$ rails c
Delayed::Job.all
Delayed::Job.last.last_error
エラーログが出ている。このログを参考にワーカーをデバッグ。

参考:
http://www.sitepoint.com/delayed-jobs-best-practices/

7
8
0

Register as a new user and use Qiita more conveniently

  1. You get articles that match your needs
  2. You can efficiently read back useful information
  3. You can use dark theme
What you can do with signing up
7
8

Delete article

Deleted articles cannot be recovered.

Draft of this article would be also deleted.

Are you sure you want to delete this article?