- xml - AJAX/Jquery XML 解析
- 具有多重继承的 XML 模式
- .net - 枚举序列化 Json 与 XML
- XML 简单类型、简单内容、复杂类型、复杂内容
我实在是无计可施了。我不明白为什么它不起作用。
我创建了一个类,我使用 rake 命令对其进行调用和排队。当我使用“rake jobs:work”运行 worker 并调用命令“rake get_updates”时,它执行得很好。
但是,当我将 worker 作为守护进程运行时 (RAILS_ENV=production bin/delayed_job start) 并调用命令“rake get_updates”时,它会产生错误。
app/workers/get_updates.rb
class GetUpdates
def perform
beginning = Time.now
include SoapHelper
require 'nokogiri'
require 'activerecord-import'
product_count = 0
contloop = true
while(contloop == true) do
@xml = Nokogiri::XML(get_unsent_data())
@guid = @xml.xpath('.//Message').attr("Id")
bulkUpdates = []
if (@xml.xpath('.//Product').count > 0)
@xml.xpath('.//Product').each do |p|
product_count += 1
update = Update.new
update.update_type = p.attr("UpdateType")
codes = Hash.new
p.children().each do |info|
info.xpath('.//ProductCodes/Code').each do |coco|
codes[coco.attr("Scheme").to_s] = coco.content
end
update.data = p.children().to_xml.to_s
end
bulkUpdates << update
end
if Update.import bulkUpdates
acknowledge_soap_receipt(@guid.to_s)
else
puts "Error, data not saved"
contloop = false
end
else
contloop = false
end
end
@time = "Time elapsed #{Time.now - beginning} seconds"
puts "Product Count: #{ product_count }"
puts @time
end
end
发条.rake
task :get_updates => :environment do
Delayed::Job.enqueue GetUpdates.new
end
在“application.rb”中自动加载路径
config.autoload_paths += %W(#{config.root}/app/workers)
config.autoload_paths += %W(#{config.root}/app/helpers)
尝试执行作业时的错误信息
Job failed to load: undefined class/module GetUpdates. Handler: "--- !ruby/object:GetUpdates {}\n\n" /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/backend/base.rb:97:in `rescue in payload_object' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/backend/base.rb:89:in `payload_object' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/backend/base.rb:105:in `block in invoke_job' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `block in initialize' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `execute' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:38:in `run_callbacks' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/backend/base.rb:102:in `invoke_job' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:206:in `block (2 levels) in run' /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/timeout.rb:69:in `timeout' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:206:in `block in run' /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/benchmark.rb:295:in `realtime' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:205:in `run' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:267:in `block in reserve_and_run_one_job' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `block in initialize' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `execute' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:38:in `run_callbacks' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:267:in `reserve_and_run_one_job' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:189:in `block in work_off' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:188:in `times' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:188:in `work_off' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:153:in `block (4 levels) in start' /usr/local/rvm/rubies/ruby-1.9.3-p448/lib/ruby/1.9.1/benchmark.rb:295:in `realtime' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:152:in `block (3 levels) in start' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `block in initialize' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `execute' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:38:in `run_callbacks' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:151:in `block (2 levels) in start' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:150:in `loop' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:150:in `block in start' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/plugins/clear_locks.rb:7:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/plugins/clear_locks.rb:7:in `block (2 levels) in <class:ClearLocks>' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:78:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:78:in `block (2 levels) in add' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:60:in `block in initialize' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:78:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:78:in `block in add' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:65:in `execute' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/lifecycle.rb:38:in `run_callbacks' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/worker.rb:149:in `start' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/command.rb:104:in `run' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/command.rb:92:in `block in run_process' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/application.rb:255:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/application.rb:255:in `block in start_proc' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/daemonize.rb:82:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/daemonize.rb:82:in `call_as_daemon' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/application.rb:259:in `start_proc' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/application.rb:296:in `start' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/application_group.rb:159:in `block (2 levels) in start_all' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/application_group.rb:158:in `fork' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/application_group.rb:158:in `block in start_all' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/application_group.rb:157:in `each' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/application_group.rb:157:in `start_all' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/controller.rb:80:in `run' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons.rb:197:in `block in run_proc' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `call' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons/cmdline.rb:109:in `catch_exceptions' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/daemons-1.1.9/lib/daemons.rb:196:in `run_proc' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/command.rb:90:in `run_process' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/command.rb:83:in `block in daemonize' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/command.rb:81:in `times' /usr/local/rvm/gems/ruby-1.9.3-p448/gems/delayed_job-4.0.0/lib/delayed/command.rb:81:in `daemonize' bin/delayed_job:6:in `<main>'
最佳答案
尝试在初始化器中加载类:
# in config/initializers/delayed_job.rb
require 'get_updates'
这应该使其可用于作业。
关于ruby-on-rails - delayed_job 作为守护进程运行时作业失败。使用 rake 作业时运行良好 :work,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18617426/
遇到这个错误。 pid-file for killed process 8600 found (C:/cyncabc/tmp/pids/delayed_job.pid), deleting.
当我部署到 pre服务器一切正常。但是如果我尝试部署到 staging服务器我收到此错误: bundler: command not found: bin/delayed_job 文件 - confi
我做了 rake db:create 然后 rake db:migrate 遇到了这个错误。 rake aborted! PGError: ERROR: relation "delayed_jobs
很难说出这里要问什么。这个问题模棱两可、含糊不清、不完整、过于宽泛或夸夸其谈,无法以目前的形式得到合理的回答。如需帮助澄清此问题以便重新打开,visit the help center . 关闭 1
我正在使用 delayed_job 并转移到一个更强大的新服务器。所以现在我想运行并行作业,就像现在一样I have the POWER! ,但对 delayed_job 是否可以运行多个并行队列感到
因此,我正在使用“延迟的作业”,并且试图弄清楚如何使我的所有邮件都被延迟。现在,我已经将handle_asynchronously放在所有的 Action 邮件程序方法中……但是我认为这行不通。 de
我正在寻找调试延迟作业类。首先,我添加了 config/initializers/delayed_job_config 以将我的日志记录移动到我的 log/production.rb 文件中。 Del
我已经有一段时间没有问题地使用 delay_job 了;主要用于排队 ActionMailer 调用(Notifier.send_later ...)。最近,它从同一工作中随机发送多封电子邮件。我将一
我在 site5.com 共享主机上使用 delayed_job(尝试了 tobi 和 collective_idea),乘客作为 rails 环境。我设法完成了工作。但是,该插件似乎在首次运行后忽略
我有 ROR 应用程序和 1 个 delay_job 进程使用 rake job:work 运行。ROR 应用在多个队列中添加 Job。 假设我们有队列 1 和队列 2。 我的问题是队列 1 中的任务
我之前设置了一个邮件程序,可以向我的所有用户帐户发送电子邮件。但现在我正在尝试调试它。所以我把它彻底清除了,它仍然给我发邮件。 我完全没有理由或理解为什么。疯狂! :D 控制者 def org_bla
我在重新启动 delayed_job 时遇到问题。 当我登录并运行 rake delayed_job RAILS_ENV=production 一切正常,所有作业都已处理,但是如果运行 RAILS_E
在安装 delayed_job gem 并在我的本地机器上成功运行后,我无法让它在我的专用服务器上运行。 我在 Gemfile 中包含了 gem“daemons”,生成了事件记录表,并成功安装/迁移了
我有一个带插件的 Rails 应用 https://github.com/tobi/delayed_job 有时作业的执行顺序与创建顺序不同。 我希望作业按照创建时的顺序执行,因为在某些情况下,要执行
我将一个作业添加到延迟的作业中,但是当我运行它时出现 NoMethod 错误 Delayed::Job.last => #Delayed::Backend::MongoMapper::Job _id:
我正在使用 delayed_job Ruby gem 就好了。 它默认为单个 worker,所以我已经完成了: script/delayed_job stop script/delayed_job -
使用 delayed_job gem,我怎样才能只停止一个进程而不停止所有工作进程? 例如: rake jobs:work 启动 worker process1 = SomeClass.enqueue
我希望我有更多信息可以放在这里,但我只是在撒网,希望有人对我可以尝试什么或寻找什么方向有一些想法。基本上我有一个使用延迟作业的 Rails 应用程序。它将需要大约 10 或 15 分钟的进程卸载到后台
我们在项目中使用 delayed_job 的命名队列。有没有办法将每个队列记录到单独的日志文件中? DelayedJob 在这样的部署脚本中启动: run "cd #{current_path};RA
我已经使用 delayed_job 在我的 Rails 应用程序中实现了长时间运行的任务连同 delayed_job_web .我的 delayed_job 配置指示作业尝试一次,并保留失败: con
我是一名优秀的程序员,十分优秀!