delayed_paperclip 使用 ActiveJob 而不是 Resque
delayed_paperclip uses ActiveJob instead of Resque
我已配置 Delayed::Paperclip 在后台处理回形针附件。我安装并配置了 Resque,根据 README,Resque 现在应该处理后台任务:
Make sure that you have Resque up and running. The jobs will be
dispatched to the :paperclip queue, so you can correctly dispatch your
worker. Configure resque and your workers exactly as you would
otherwise.
但是,运行ning 后台任务的另一个框架 Active Job 作为 Rails 4.1/ActionMailer 的依赖项安装,它 "steals" 来自 Resque 的任务。
[ActiveJob] Enqueued DelayedPaperclip::Jobs::ActiveJob (Job ID: ba60f576-e544-4f53-8db2-eb0085f1f653) to Inline(paperclip) with arguments: "Photo", 79, "picture"
问题是 Active Job 似乎 运行 立即在同一线程中运行 - 基本上它根本不会 运行 在后台运行。
我检查了 Delayed::Paperclip 的代码,安装的后端似乎有优先级:
def detect_background_task
return DelayedPaperclip::Jobs::ActiveJob if defined? ::ActiveJob::Base
return DelayedPaperclip::Jobs::DelayedJob if defined? ::Delayed::Job
return DelayedPaperclip::Jobs::Resque if defined? ::Resque
return DelayedPaperclip::Jobs::Sidekiq if defined? ::Sidekiq
end
当我调换它们并将 Resque 放在最上面时,它起作用了。优先级似乎是硬编码的,但我想如果是这样的话,我不会是唯一遇到这个问题的人。这是一个错误还是我遗漏了什么?
Active Job 实际上是一个非常好的主要选择,因为它充当抽象层:
Active Job is a framework for declaring jobs and making them run on a
variety of queueing backends. [...] The main point is to ensure that all
Rails apps will have a job infrastructure in place, even if it's in
the form of an "immediate runner".
默认为 运行 立即执行任务,但也可以选择其他后端。这些后端之一是 Resque。所以你唯一需要做的就是配置 Active Job 来使用 Resque:Delayed::Paperclip → Active Job → Resque。只需将其放入您的 application.rb
:
module MyApp
class Application < Rails::Application
...
config.active_job.queue_adapter = :resque
end
end
可能应该更新 Delayed::Paperclip 自述文件。
我已配置 Delayed::Paperclip 在后台处理回形针附件。我安装并配置了 Resque,根据 README,Resque 现在应该处理后台任务:
Make sure that you have Resque up and running. The jobs will be dispatched to the :paperclip queue, so you can correctly dispatch your worker. Configure resque and your workers exactly as you would otherwise.
但是,运行ning 后台任务的另一个框架 Active Job 作为 Rails 4.1/ActionMailer 的依赖项安装,它 "steals" 来自 Resque 的任务。
[ActiveJob] Enqueued DelayedPaperclip::Jobs::ActiveJob (Job ID: ba60f576-e544-4f53-8db2-eb0085f1f653) to Inline(paperclip) with arguments: "Photo", 79, "picture"
问题是 Active Job 似乎 运行 立即在同一线程中运行 - 基本上它根本不会 运行 在后台运行。
我检查了 Delayed::Paperclip 的代码,安装的后端似乎有优先级:
def detect_background_task
return DelayedPaperclip::Jobs::ActiveJob if defined? ::ActiveJob::Base
return DelayedPaperclip::Jobs::DelayedJob if defined? ::Delayed::Job
return DelayedPaperclip::Jobs::Resque if defined? ::Resque
return DelayedPaperclip::Jobs::Sidekiq if defined? ::Sidekiq
end
当我调换它们并将 Resque 放在最上面时,它起作用了。优先级似乎是硬编码的,但我想如果是这样的话,我不会是唯一遇到这个问题的人。这是一个错误还是我遗漏了什么?
Active Job 实际上是一个非常好的主要选择,因为它充当抽象层:
Active Job is a framework for declaring jobs and making them run on a variety of queueing backends. [...] The main point is to ensure that all Rails apps will have a job infrastructure in place, even if it's in the form of an "immediate runner".
默认为 运行 立即执行任务,但也可以选择其他后端。这些后端之一是 Resque。所以你唯一需要做的就是配置 Active Job 来使用 Resque:Delayed::Paperclip → Active Job → Resque。只需将其放入您的 application.rb
:
module MyApp
class Application < Rails::Application
...
config.active_job.queue_adapter = :resque
end
end
可能应该更新 Delayed::Paperclip 自述文件。