# Drb problem? ringy-dingy won't answer

**URL:** <https://www.ruby-forum.com/t/drb-problem-ringy-dingy-wont-answer/226071>\
**Category:** Ruby\
**Created:** [July 1, 2010, 1:40am UTC](https://www.ruby-forum.com/t/drb-problem-ringy-dingy-wont-answer/226071 "2010-07-01T01:40:47Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![koicat](https://www.ruby-forum.com/letter_avatar_proxy/v4/letter/k/b19c9b/32.png) [@koicat](https://www.ruby-forum.com/u/koicat)\
**Post date:** [July 1, 2010, 1:40am UTC](https://www.ruby-forum.com/t/drb-problem-ringy-dingy-wont-answer/226071/1 "2010-07-01T01:40:47Z")

</div>

The following code works fine as long as I don’t try to run it through  
the distributed server. It doesn’t get there…  
It runs fine out of delayed\_job, runs fine if called directly.  
But if ‘distrib’ is true (the default) it runs right up to the call to  
the server and right past it without getting to the server or raising  
any errors.

Am using Ruby 1.8.6.26 , Ringy-Dingy 1.2.1, dj 1.8.4.

\*\*\*\*\*\*\*\*\*The server:  
require ‘rinda/ring’  
class ScriptServer  
include DRbUndumped  
attr\_accessor :result  
def run(fullScript)  
myTS = Time.now.strftime("%Y%m%d%H%M%S")  
msg = “===\> Starting #{scriptname} in run #{scriptrun} on  
#{scriptenv} at #{myTS}”  
puts msg  
@result = “\*\*\*#{scriptname} Launched [#{scriptlaunch}]”  
rslt = fullScript.run  
@result \<\< rslt  
msg = “#{scriptname} Completed [#{Time.now.strftime(”%Y%m%d%H%M  
%S")}]"  
@result \<\< “\*\*\*#{msg}”  
rescue  
@result \<\< “#{scriptname} Aborted [#{Time.now.strftime(”%Y%m%d%H%M  
%S")}] \n #{$!} \n #{caller.to\_yaml}"  
ensure  
return @result  
end  
end  
DRb.start\_service  
myPid = Process.pid.to\_s  
puts myPid  
ring\_server = Rinda::RingFinger.primary  
ring\_server.write([:name,  
:ScriptServer,  
ScriptServer.new(),  
“ScriptServer #{myPid}”],  
Rinda::SimpleRenewer.new)  
DRb.thread.join

\*\*\*\*\*\*\*\* The worker/client  
require ‘active\_support’  
require ‘drb’

class ScriptWorker

attr\_accessor :script\_id  
attr\_accessor :run\_id  
attr\_accessor :distrib

def initialize( script\_id, run\_id, distrib = true )  
self.script\_id = script\_id  
self.run\_id = run\_id  
self.distrib = distrib  
@myLog = ‘’  
end

def perform  
myScript = Script.find(script\_id)

# left out setting of variables used below…

```
require "#{myRoot}/script/#{myScript.name}"

fullScript = Object.const_get(myClass).new( myScript, myRun,

```

runenv, myURI, myRoot )

if self.distrib  
require ‘rinda/ring’  
DRb.start\_service  
ring\_server = Rinda::RingFinger.primary  
service = ring\_server.take([:name, :ScriptServer, nil, nil])  
server = service[2]  
result = server.run(fullScript)  
puts result  
else  
result = fullScript.run  
puts result  
end  
@myLog.close  
end

def init\_my\_log( name )  
…  
end  
end

\*\*\*\*\*\*\*\* The parent script class  
require ‘rubygems’  
require ‘util1’  
require ‘drb’

class ScriptMain

currDir = Dir.pwd

include Util1  
include DRbUndumped

def initialize( aScript, aRun, runenv, myURI, myRoot )  
@myScript = aScript  
@myId = @myScript.id  
@myName = File.basename(@myScript.name, “\*.rb”)  
@usecase = @myName  
@myRun = aRun  
@myRoot = myRoot  
@rootDir = “#{RAILS\_ROOT}”  
@launch = aRun.launched  
@runenv = runenv  
@myURI = myURI  
@runid = aRun.id  
@optionStrg = aRun.options  
@myBrowser = ‘’  
@myHwnd = 0

end  
end

\*\*\*\*\*\*\*\*\*\*a sample child script class  
(Just the run method. bunch of other methods in full script)

class SearchTest \< ScriptMain

def run( limit = 5.minutes )  
begin  
puts ‘&_&_&\* I am here _&_&\*&’  
@runenv = ‘WEB’  
open\_log(@myName, @rootDir, @myRoot, @launch, @start,  
@myId, @runenv, @usecase, @runid, @optionStrg )

```
  mark_testlevel('Test Parent', 7) # Module
  mark_testlevel('Test Child', 6) # SubModule

  @myBrowser = Watir::IE.new_process
  @myHwnd = @myBrowser.hwnd
  lookup('Google')
  emaillogin(@myBrowser, @service, @username, @password)
  logout(@myBrowser)

rescue
  log_message(FATAL, "(#{ __LINE__ }) #{$!}", @@fail)
  raise
ensure
  create_flag_file(Time.new.to_f.to_s, 'parse' ) unless @runid ==

```

‘99999’  
close\_log(@myName, **LINE** )  
end  
end #def

end
