Skip to content

Instantly share code, notes, and snippets.

@bfaloona
Created April 15, 2010 07:44
Show Gist options
  • Save bfaloona/366809 to your computer and use it in GitHub Desktop.
Save bfaloona/366809 to your computer and use it in GitHub Desktop.
>> require 'drb'
=> true
>> client = DRbObject.new( nil, 'druby://:1234')
=> #<DRb::DRbObject:0x1016c8c78 @ref=nil, @uri="druby://:1234">
>> client.connection
=> 1
>> client.cookbook do
?> return true
>> end
DRb::DRbConnError: DRb::DRbServerNotFound
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/drb/drb.rb:1657:in `current_server'
from /System/Library/Frameworks/Ruby.framework/Versions/1.8/usr/lib/ruby/1.8/drb/drb.rb:1725:in `to_id'
>>
>> ... etc ...
>>
>> client.connection
=> 2
>> require 'task_master_server'
=> true
>> TaskMaster1.start
require 'drb'
class TaskMaster1
@@counter = 0
def self.connection
@@counter+=1
end
def self.start
DRb.start_service("druby://:1234", TaskMaster1)
DRb.thread.join
end
def self.stop
DRb.stop_service
end
# accepts a block of code
def self.cookbook( &block )
instance_eval &block
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment