Class: Meroku::Node
Overview
A node is an ec2 node, that powers meroku
Instance Attribute Summary collapse
-
#connection ⇒ Object
readonly
Returns the value of attribute connection.
-
#instance_id ⇒ Object
readonly
Returns the value of attribute instance_id.
Instance Method Summary collapse
- #close_ssh ⇒ Object
- #execute(command) ⇒ Object
- #execute_script(script) ⇒ Object
-
#initialize ⇒ Node
constructor
A new instance of Node.
- #start_ssh ⇒ Object
Methods included from Aws
#allocation_id, #associate_address, #bucket, #ip_address, #make_instance, running_filter, #tag, terminate_all
Methods included from Shared
Constructor Details
#initialize ⇒ Node
Returns a new instance of Node.
10 11 12 13 14 15 16 17 |
# File 'lib/meroku/node.rb', line 10 def initialize make_instance && associate_address start_ssh && configure_keys install_packages database_inits && git_clone nginx_configs && start_rails && close_ssh puts 'Node created' end |
Instance Attribute Details
#connection ⇒ Object (readonly)
Returns the value of attribute connection.
8 9 10 |
# File 'lib/meroku/node.rb', line 8 def connection @connection end |
#instance_id ⇒ Object (readonly)
Returns the value of attribute instance_id.
8 9 10 |
# File 'lib/meroku/node.rb', line 8 def instance_id @instance_id end |
Instance Method Details
#close_ssh ⇒ Object
30 31 32 |
# File 'lib/meroku/node.rb', line 30 def close_ssh @connection.close end |
#execute(command) ⇒ Object
34 35 36 37 |
# File 'lib/meroku/node.rb', line 34 def execute(command) @connection.exec(command) { |_ch, _stream, data| puts data } @connection.loop end |
#execute_script(script) ⇒ Object
19 20 21 22 23 24 |
# File 'lib/meroku/node.rb', line 19 def execute_script(script) script.each_line do |line| puts line execute(line) end end |
#start_ssh ⇒ Object
26 27 28 |
# File 'lib/meroku/node.rb', line 26 def start_ssh @connection = Net::SSH.start(ip_address, 'ubuntu', sshopts) end |