所以,我有一个代码,是 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。