[Backgroundrb-devel] Neophyte needs help!
todd Richmond
twr at frii.com
Wed May 9 00:11:36 EDT 2007
Hi All,
Real neophyte here, to both backgroundrb and ruby/rails in general.
(Hey, we've all got to start somewhere, right!) :)
I've just been playing around with the example code at
http://backgroundrb.rubyforge.org/ , and trying to get all
the pieces to work (btw, I'm using version 0.2.1).
I did a 'generate worker example', which created an example_worker.rb
file in my ./libs/workers directory.
I fleshed it out so it looks like this (as per the example in the
documentation):
#####################################################################
class ExampleWorker < BackgrounDRb::Worker::RailsBase
def do_work(args)
logger.info('ExampleWorker do work')
results[:do_work_time] = Time.now.to_s
results[:done_with_do_work] ||= true
end
def other_method
logger.info('other_method in ExampleWorker called')
results[:extra_data] = "Just a plain old string"
end
def arg_method(arg)
end
end
ExampleWorker.register
#####################################################################
Next, I created a 'backgroundrb_example' file under ./script. It looks
like this:
#####################################################################
#!/usr/bin/env ruby
require File.dirname(__FILE__) + '/../config/boot'
require "#{RAILS_ROOT}/config/environment"
key = MiddleMan.new_worker(:class => :example_worker)
worker = MiddleMan.worker(key)
worker.other_method
worker.delete
#####################################################################
I also started the backgroundrb server, and it and the other processes
seem to be running fine:
todd 6865 0.0 0.6 16484 13372 ? S 21:20 0:00
backgroundrb
todd 6866 0.0 0.6 16320 13168 ? S 21:20 0:00
backgroundrb_logger
todd 6867 0.0 0.6 16520 13384 ? S 21:20 0:00
backgroundrb_results
My config file looks like this:
:host: localhost
:port: 22222
:worker_dir: lib/workers
:rails_env: development
:pool_size: 15
:acl:
:deny: all
:allow: localhost 127.0.0.1
:order: deny allow
When I try to run the example, I get a NameError because it can't seem
to
find my ExampleWorker class:
ruby backgroundrb_example
(drbunix:///tmp/backgroundrbunix_localhost_22222) /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:266:in `load_missing_constant': uninitialized constant ExampleWorker (NameError)
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:452:in `const_missing'
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) /usr/local/lib/ruby/gems/1.8/gems/activesupport-1.4.1/lib/active_support/dependencies.rb:464:in `const_missing'
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) /home/todd/devel/pedperf/trunk/site_app/vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:453:in `worker_klass_constant'
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) /home/todd/devel/pedperf/trunk/site_app/vendor/plugins/backgroundrb/server/lib/backgroundrb/middleman.rb:178:in `new_worker'
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) /usr/local/lib/ruby/1.8/drb/drb.rb:1552:in `perform_without_block'
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) /usr/local/lib/ruby/1.8/drb/drb.rb:1512:in `perform'
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) /usr/local/lib/ruby/1.8/drb/drb.rb:1586:in `main_loop'
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) /usr/local/lib/ruby/1.8/drb/drb.rb:1582:in `main_loop'
... 13 levels...
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) /usr/local/lib/ruby/gems/1.8/gems/daemons-1.0.5/lib/daemons.rb:181:in `run_proc'
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) /home/todd/devel/pedperf/trunk/site_app/vendor/plugins/backgroundrb/server/lib/backgroundrb_server.rb:301:in `run'
from
(drbunix:///tmp/backgroundrbunix_localhost_22222) ./script/backgroundrb:29
from backgroundrb_example:6
Any help would be greatly appreciated!
Thanks,
Todd Richmond
-------------- next part --------------
An HTML attachment was scrubbed...
URL: http://rubyforge.org/pipermail/backgroundrb-devel/attachments/20070508/745cdaba/attachment.html
More information about the Backgroundrb-devel
mailing list