Monday, August 24, 2009

Using BackgrounDRb

Since I'm having so many issues with BackgrounDRb, I thought I should write down how I'm solving issues - I expect some other people are also experiencing! ;)
I'm assuming that you have already installed it, but if not I wrote up some basic notes here.

Monitoring the task queue

# script/console
# MiddleMan.all_worker_info

This will show you what workers are available, and what if they are currently running.

From Code

#!/usr/bin/env ruby


#load required rails and backgroundrb files
require File.dirname(__FILE__) + '/../config/boot'
require File.dirname(__FILE__) + '/../config/environment'
require 'erb'
$LOAD_PATH << "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib" require "#{RAILS_ROOT}/vendor/plugins/backgroundrb/lib/backgroundrb.rb" class BackgroundMonitor def test begin puts "Raw data:" puts MiddleMan.all_worker_info puts puts "Individual:" puts { |w| puts w[:worker] puts " key = #{w[:worker_key]}" puts " status = #{w[:status]}" } rescue puts "Some kind of problem occurred..." end end end monitor = monitor.test

No comments: