Sha256: fef556a9fe8c1c09c463578433dde02152b6c90741ec2c1f9f366502c3fc3d12
Contents?: true
Size: 1.62 KB
Versions: 8
Compression:
Stored size: 1.62 KB
Contents
module Pione module Front # FrontError is raised when front server cannnot start. class FrontError < StandardError; end # This is base class for all PIONE front classes. PIONE fronts exist in each # command and control its process. class BasicFront < PioneObject include DRbUndumped extend Forwardable attr_reader :command attr_reader :uri attr_reader :attrs attr_reader :link # Creates a front server as druby's service. def initialize(command, port) @command = command # @uri = start_service(port, {:verbose => true}) @uri = start_service(port, {}) @attrs = {} end # Returns the pid. def pid Process.pid end def link @__link__ end # Terminates the front. def terminate DRb.stop_service end private # Starts drb service and returns the URI. def start_service(port, config) if port.kind_of?(Range) port = port.each begin uri = "druby://%s:%s" % [Global.my_ip_address, port.next] @__link__ = DRb.start_service(uri, self, config) rescue StopIteration => e raise FrontError.new("You couldn't start front server.") rescue retry end else begin DRb.start_service(port ? "druby://%s:%s" % [Global.my_ip_address, port] : nil, self, config) rescue => e raise FrontError.new("You couldn't start front server: %s" % e.message) end end return DRb.uri end end end end
Version data entries
8 entries across 8 versions & 1 rubygems