Running backgroundrb jobs, where do they run from?

Hey all

Im setting up a system that uses the excellent backgroundrb. However i
want to use the very cool directroy watcher ( ) to
monitor a directory, however i keep getting an error saying the
directory doesnt exsist.

Im running this from the models folder of a rails app, so where might it
be running from? Ive tried going from RAILS_ROOT, ive even run it
independantly - in which scenario it works, however i can only presume
backgroundrb must be running from a different location?

i was wondering if it somhow might be running centered around the config
dir as thats where the backgroundrb config file is?

Any help would be greatly appreciated!



On Sep 27, 2006, at 7:53 AM, Tim P. wrote:

might it


Hey Tim-

I'm not sure exactly what you are asking? You are trying to run the

DriWatch from a bdrb worker class? If so just use either the absolute
path to the directory or RAILS_ROOT is available in your worker
classes so you can base the path on that. ie: RAILS_ROOT+’/foo/bar/baz’


Hey Ezra

Thanks for getting back to me. Yea thats exactly what im trying to do, i
just tried the following code…

in my controller

def start
session[:job_key] = MiddleMan.new_worker(:class => :watch_worker,
:args => { :dir => RAILS_ROOT + “/hotfolders/in”, :delay => 2})
redirect_to(:action => ‘results’)
redirect_to(:action => ‘index’)

in my worker

def do_work(args)
@logger.error = ‘Booting hotfolder watcher…’
device_manager =[:dir], args[:delay])
device_manager.name_regexp = /^[^.].*.xml$/
device_manager.on_add ={ |the_file|
@logger.error “Hey, just found #{the_file.inspect}!”

It doesnt error and returns a DRB object that persists, so i can only
presume its working. However when i try to get it to log - so i can
“see” its working - i just get errors in the backgroundrb log like…

undefined method `error=’ for #Logger:0x223e0a8 - (NoMethodError)


undefined method `debug=’ for #Logger:0x223e0a8 - (NoMethodError)

depending on the method call i use. In usual rails code we can write
logger.error(‘some error message’) and it gets logged to the enviroment
log. Whats the correct call i should be using to make it log correctly?

This forum is not affiliated to the Ruby language, Ruby on Rails framework, nor any Ruby applications discussed here.

| Privacy Policy | Terms of Service | Remote Ruby Jobs