Class: Dorsal::Controller
- Inherits:
-
Object
- Object
- Dorsal::Controller
- Includes:
- Privates
- Defined in:
- lib/dorsal/controller.rb
Overview
the Controller Class, provide access and control of the Ring Server and services, via the Ring Server
Instance Attribute Summary collapse
- #options ⇒ Object readonly
Instance Method Summary collapse
-
#bind_to_ring ⇒ DRbObject?
accessor to ring server if up.
-
#initialize(_options = {}) ⇒ Controller
constructor
contructor for Dorsal::Controller.
-
#ring_server_status ⇒ TrueClass, FalseClass
return the running status of the ring server.
-
#start_ring_server ⇒ Fixnum, FalseClass
start the ring server if not.
-
#stop_ring_server ⇒ TrueClass, FalseClass
stop the ring server if up.
Methods included from Privates
#daemonize, #start, #status, #stop
Constructor Details
#initialize(_options = {}) ⇒ Controller
Note:
see default values from Dorsal namespace Constants
contructor for Dorsal::Controller
50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 |
# File 'lib/dorsal/controller.rb', line 50 def initialize( = {}) @options = Methodic::() @options.specify_defaults_values :description => Dorsal::DEFAULT_RINGSERVER_DESCRIPTION, :debug => Dorsal::DEFAULT_DEBUG, :host => Dorsal::DEFAULT_HOST, :port => Dorsal::DEFAULT_PORT, :dir => Dorsal::DEFAULT_DIR @options.merge @options[:dir].chomp!('/') @options[:name] = Dorsal::DEFAULT_RINGSERVER_NAME @options[:uri] = "druby://#{[:host]}:#{[:port]}" Dir::mkdir(@options[:dir]) unless File::exist?(@options[:dir]) @options[:pid_file] = "#{@options[:dir]}/#{@options[:name]}.pid" @options[:object] = Dorsal::ImplementationServer::new({ :dir => @options[:dir], :host => @options[:host], :debug => @options[:debug]}) end |
Instance Attribute Details
#options ⇒ Object (readonly)
34 35 36 |
# File 'lib/dorsal/controller.rb', line 34 def @options end |
Instance Method Details
#bind_to_ring ⇒ DRbObject?
accessor to ring server if up
72 73 74 75 76 77 78 79 |
# File 'lib/dorsal/controller.rb', line 72 def bind_to_ring if ring_server_status then DRb.start_service return DRbObject.new nil, @options[:uri] else return nil end end |
#ring_server_status ⇒ TrueClass, FalseClass
return the running status of the ring server
127 128 129 |
# File 'lib/dorsal/controller.rb', line 127 def ring_server_status return status @options end |
#start_ring_server ⇒ Fixnum, FalseClass
start the ring server if not
87 88 89 90 91 92 93 94 95 96 97 98 |
# File 'lib/dorsal/controller.rb', line 87 def start_ring_server unless ring_server_status then res = start(@options) do DRb.start_service(@options[:uri], @options[:object]) DRb.thread.join end return res else return false end end |
#stop_ring_server ⇒ TrueClass, FalseClass
stop the ring server if up
107 108 109 110 111 112 113 114 115 116 117 |
# File 'lib/dorsal/controller.rb', line 107 def stop_ring_server if ring_server_status then ring = self.bind_to_ring ring.list_services.keys.each do |service| ring.destroy_service :name => service end return stop @options else return false end end |