Created
April 15, 2010 07:44
-
-
Save bfaloona/366809 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
>> require 'task_master_server' | |
=> true | |
>> TaskMaster1.start |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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