gpt4 book ai didi

ruby-on-rails - Sidekiq 卡住应用程序

转载 作者:IT王子 更新时间:2023-10-29 06:07:54 25 4
gpt4 key购买 nike

所以,我有一个代码,是 rake 任务的一部分:

  class DrivingStatJob < DBJob
sidekiq_options :queue => :driving_stats, :backtrace => true

def perform(work_order_id)
Rails.logger.info "Calculating driving stats for work_order #{work_order_id}"
begin
work_order = WorkOrder.find(work_order_id)
return unless work_order.steps.size > 1
DrivingStat.calculate!(work_order.steps.first.location.address, work_order.steps.last.location.address)
rescue DrivingStatService::MissingCoordinatesError
Rails.logger.warn "Unable to fetch coorindates for work order #{work_order_id}"
rescue ActiveRecord::RecordInvalid => e
Rails.logger.warn "Unable to save driving stat: #{e.message}"
rescue ActiveRecord::RecordNotFound
# Ignore
rescue RuntimeError => e
Rails.logger.warn "Unable to compute driving directions"
Rails.logger.warn [e.message, e.backtrace].join("\n")
end
end
end

调用“执行”的代码:

begin
DrivingStatJob.perform_async(id) if changed
rescue Redis::CannotConnectError => e
logger.warn "Unable to queue up driving stats job"
logger.warn [e.message, e.backtrace].join("\n")
end

问题:它卡在 DrivingStatJob.perform_async(id) 上。它只是挂起,没有错误。 “执行”功能没有日志消息。它可能是什么? Redis 正常运行,sidekiq 正常运行。 Redis 在 127.0.0.1:6379 上运行,Sidekiq 显示它知道 Redis 在那里。

Linux Mint 15、Ruby 1.9.3、Redis 2.6、sidekiq-2.14。

最佳答案

很难说发生了什么。一种找出方法是在您的 perform 方法中放置一个 debugger 并在前台运行一个 sidekiq worker。这让您有机会逐步了解这些方法。

你最终会进入 Sidekiq::Clients push method .这就是有趣的地方。

bundle exec sidekiq

对于 1.9,您可以使用 debugger gem .

关于ruby-on-rails - Sidekiq 卡住应用程序,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18927590/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com