Class: Meroku::Node

Inherits:
Object
  • Object
show all
Includes:
Aws, Shared
Defined in:
lib/meroku/node.rb

Overview

A node is an ec2 node, that powers meroku

Instance Attribute Summary collapse

Instance Method Summary collapse

Methods included from Aws

#allocation_id, #associate_address, #bucket, #ip_address, #make_instance, running_filter, #tag, terminate_all

Methods included from Shared

ec2_client

Constructor Details

#initializeNode

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

#connectionObject (readonly)

Returns the value of attribute connection.



8
9
10
# File 'lib/meroku/node.rb', line 8

def connection
  @connection
end

#instance_idObject (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_sshObject



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_sshObject



26
27
28
# File 'lib/meroku/node.rb', line 26

def start_ssh
  @connection = Net::SSH.start(ip_address, 'ubuntu', sshopts)
end