Hey all Im setting up a system that uses the excellent backgroundrb. However i want to use the very cool directroy watcher ( http://phrogz.net/RubyLibs/rdoc/files/DirectoryWatcher_rb.html ) 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! Cheers Tim -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
Ezra Zygmuntowicz
2006-Sep-27 20:04 UTC
Re: Running backgroundrb jobs, where do they run from?
On Sep 27, 2006, at 7:53 AM, Tim Perrett wrote:> > Hey all > > Im setting up a system that uses the excellent backgroundrb. However i > want to use the very cool directroy watcher ( > http://phrogz.net/RubyLibs/rdoc/files/DirectoryWatcher_rb.html ) 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! > > Cheers > > TimHey 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'' -Ezra --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---
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 begin session[:job_key] = MiddleMan.new_worker(:class => :watch_worker, :args => { :dir => RAILS_ROOT + "/hotfolders/in", :delay => 2}) redirect_to(:action => ''results'') rescue redirect_to(:action => ''index'') end end ## in my worker def do_work(args) @logger.error = ''Booting hotfolder watcher...'' device_manager = Dir::DirectoryWatcher.new(args[:dir], args[:delay]) device_manager.name_regexp = /^[^.].*\.xml$/ device_manager.on_add = Proc.new{ |the_file| @logger.error "Hey, just found #{the_file.inspect}!" } end 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) OR 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? -- Posted via http://www.ruby-forum.com/. --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Ruby on Rails: Talk" group. To post to this group, send email to rubyonrails-talk-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org To unsubscribe from this group, send email to rubyonrails-talk-unsubscribe-/JYPxA39Uh5TLH3MbocFFw@public.gmane.org For more options, visit this group at http://groups.google.com/group/rubyonrails-talk -~----------~----~----~----~------~----~------~--~---