Sha256: 122bee9fd168a849502472f7f393938fdc0cd62a2bfc5cf580dba0d56bcb8eef
Contents?: true
Size: 1.86 KB
Versions: 1
Compression:
Stored size: 1.86 KB
Contents
#!/usr/bin/env ruby -w require 'rinda/ring' require 'rinda/tuplespace' require 'rubygems' require 'logger' require 'optparse' require 'pp' class Rinda::TupleSpaceProxy def take(tuple, sec=nil, &block) port = [] port.push @ts.move(nil, tuple, sec, &block) port[0] end end class Rinda::Tuple require 'ostruct' def init_with_ary(ary) if ary.instance_of?(DRb::DRbUnknown) begin Marshal.load(ary.buf) rescue Exception => e raise Rinda::RindaError.new("DRb couldn't marshall tuple of type #{ary.name}, it was turned into a DRb::DRbUnknown object.\nMarshal exception #{e.inspect}\nOriginal object:\n\t#{ary.buf}.\n\nStacktrace:\n") end else @tuple = Array.new(ary.size) @tuple.size.times do |i| @tuple[i] = ary[i] end end end end class Skynet class Task end class Message class Payload end end class AsyncJob end class Job end class Server def initialize(options) log = Logger.new(options[:logfile], 'weekly') log.level = Object.module_eval("#{"Logger::" + options[:loglevel].upcase}", __FILE__, __LINE__) log.info "STARTING SKYNET SERVER ON PORT: #{options[:port]} Logging to #{options[:logfile]}" # Create a TupleSpace to hold named services, and start running begin ts = Rinda::TupleSpace.new if options[:drburi] DRb.start_service(options[:drburi], ts) else DRb.start_service end tuple = [:name,:TupleSpace, ts, 'Tuple Space'] renewer = Rinda::SimpleRenewer.new ring_ts = Rinda::TupleSpace.new ring_ts.write(tuple, renewer) server = Rinda::RingServer.new(ring_ts, options[:port]) DRb.thread.join rescue Exception, RuntimeError => e log.fatal "Couldn't start Skynet Server #{e.inspect}" end end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
skynet-0.9.2 | lib/skynet/skynet_tuplespace_server.rb |