Class: Rubyang::Database::ComponentManager::Component
- Inherits:
-
Object
- Object
- Rubyang::Database::ComponentManager::Component
- Defined in:
- lib/rubyang/database/component_manager.rb
Instance Attribute Summary collapse
-
#hook ⇒ Object
readonly
Returns the value of attribute hook.
-
#instance ⇒ Object
readonly
Returns the value of attribute instance.
-
#name ⇒ Object
readonly
Returns the value of attribute name.
-
#path ⇒ Object
readonly
Returns the value of attribute path.
-
#sock ⇒ Object
readonly
Returns the value of attribute sock.
-
#thread ⇒ Object
readonly
Returns the value of attribute thread.
Instance Method Summary collapse
-
#initialize(name, hook, path) ⇒ Component
constructor
A new instance of Component.
- #run ⇒ Object
- #start ⇒ Object
Constructor Details
#initialize(name, hook, path) ⇒ Component
Returns a new instance of Component.
14 15 16 17 18 19 |
# File 'lib/rubyang/database/component_manager.rb', line 14 def initialize name, hook, path @name = name @hook = hook @path = path @sock = "/tmp/rubyang/component/#{@name}.sock" end |
Instance Attribute Details
#hook ⇒ Object (readonly)
Returns the value of attribute hook.
12 13 14 |
# File 'lib/rubyang/database/component_manager.rb', line 12 def hook @hook end |
#instance ⇒ Object (readonly)
Returns the value of attribute instance.
12 13 14 |
# File 'lib/rubyang/database/component_manager.rb', line 12 def instance @instance end |
#name ⇒ Object (readonly)
Returns the value of attribute name.
12 13 14 |
# File 'lib/rubyang/database/component_manager.rb', line 12 def name @name end |
#path ⇒ Object (readonly)
Returns the value of attribute path.
12 13 14 |
# File 'lib/rubyang/database/component_manager.rb', line 12 def path @path end |
#sock ⇒ Object (readonly)
Returns the value of attribute sock.
12 13 14 |
# File 'lib/rubyang/database/component_manager.rb', line 12 def sock @sock end |
#thread ⇒ Object (readonly)
Returns the value of attribute thread.
12 13 14 |
# File 'lib/rubyang/database/component_manager.rb', line 12 def thread @thread end |
Instance Method Details
#run ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/rubyang/database/component_manager.rb', line 37 def run begin @instance.run rescue => e puts "Error: #{e}" end end |
#start ⇒ Object
21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 |
# File 'lib/rubyang/database/component_manager.rb', line 21 def start begin @thread = Thread.new( @path ) do |path| stdout, stderr, status = Open3.capture3( "#{RUBY_ENGINE} #{path}" ) end 10.times{ |i| break if File.socket? @sock sleep 1 raise "Load failed: #{@name} : #{@path}" if i == 9 } @instance = DRbObject.new_with_uri( "drbunix:#{@sock}" ) rescue => e puts "Error: #{e}" end end |