0
我有一個scraper設置爲使用delayed_job,以便它在後臺運行。現在Delayed_job突然似乎沒有做任何事情?
class Scraper
def do_scrape
# do some scraping stuff
end
handle_asynchronously :do_scrape
end
我可以註釋掉handle_asynchronously
線,打開控制檯並運行刮板就好了。它的確如我所期望的那樣。
但是,當我嘗試將刮擦作爲延遲工作時,它似乎沒有做任何事情。此外,它似乎也沒有記錄任何重要的事情。
下面是我的日誌從入隊作業到運行rake jobs:work
的方式。
County Load (1.0ms) SELECT "counties".* FROM "counties" WHERE "counties"."name" = 'Fermanagh' LIMIT 1
(0.1ms) BEGIN
SQL (20.5ms) INSERT INTO "delayed_jobs" ("attempts", "created_at", "failed_at", "handler", "last_error", "locked_at", "locked_by", "priority", "run_at", "updated_at") VALUES ($1, $2, $3, $4, $5, $6, $7, $8, $9, $10) RETURNING "id" [["attempts", 0], ["created_at", Mon, 30 May 2011 21:19:25 UTC +00:00], ["failed_at", nil], ["handler", "---
# serialized object omitted for conciseness
nmethod_name: :refresh_listings_in_the_county_without_delay\nargs: []\n\n"], ["last_error", nil], ["locked_at", nil], ["locked_by", nil], ["priority", 0], ["run_at", Mon, 30 May 2011 21:19:25 UTC +00:00], ["updated_at", Mon, 30 May 2011 21:19:25 UTC +00:00]]
(0.9ms) COMMIT
Delayed::Backend::ActiveRecord::Job Load (0.4ms) SELECT "delayed_jobs".* FROM "delayed_jobs" WHERE (locked_by = 'host:David-Tuites-MacBook-Pro.local pid:7743' AND locked_at > '2011-05-30 17:19:32.116511') LIMIT 1
(0.1ms) BEGIN
SQL (0.3ms) DELETE FROM "delayed_jobs" WHERE "delayed_jobs"."id" = $1 [["id", 42]]
(0.4ms) COMMIT
正如你所看到的,它似乎只是插入一份工作,然後馬上刪除它?這種刮擦方法至少需要幾分鐘。
最糟糕的部分是,它昨天晚上工作完美,我想不出一件事我做的不同。我試圖修復它以前版本的寶石,因爲它最近更新了,但似乎沒有解決問題。
任何想法?
我根本沒有這個設置,但是我把它放進去並設置爲false。現在我被告知'作業未能加載:分配器未定義爲Proc。 Handler'。有點谷歌搜索告訴我,我可能會得到這個錯誤,因爲我試圖拖延的工作太複雜了,所以我想我會盡力處理這個問題。謝謝。 – 2011-05-30 23:16:29
我簡化了一些東西,這似乎有所幫助。 – 2011-05-30 23:32:22
good going .... :) – 2011-06-01 00:39:17