Class: Zombees::Worker
- Inherits:
-
Object
- Object
- Zombees::Worker
- Extended by:
- Forwardable
- Includes:
- Celluloid, Yell::Loggable
- Defined in:
- lib/zombees/worker.rb
Instance Attribute Summary collapse
-
#config ⇒ Object
readonly
Returns the value of attribute config.
-
#server ⇒ Object
readonly
Returns the value of attribute server.
Instance Method Summary collapse
- #bootstrap ⇒ Object
-
#initialize(connection) ⇒ Worker
constructor
A new instance of Worker.
- #run_command(command) ⇒ Object
- #shutdown ⇒ Object
Constructor Details
#initialize(connection) ⇒ Worker
Returns a new instance of Worker.
17 18 19 |
# File 'lib/zombees/worker.rb', line 17 def initialize(connection) @connection = connection end |
Instance Attribute Details
#config ⇒ Object (readonly)
Returns the value of attribute config.
12 13 14 |
# File 'lib/zombees/worker.rb', line 12 def config @config end |
#server ⇒ Object (readonly)
Returns the value of attribute server.
13 14 15 |
# File 'lib/zombees/worker.rb', line 13 def server @server end |
Instance Method Details
#bootstrap ⇒ Object
21 22 23 24 25 26 27 28 29 30 |
# File 'lib/zombees/worker.rb', line 21 def bootstrap @server = @connection.servers.bootstrap( private_key_path: 'tourfleet', key_name: :fog_default, username: 'ubuntu' ) @server.wait_for { ready? } self end |
#run_command(command) ⇒ Object
32 33 34 35 |
# File 'lib/zombees/worker.rb', line 32 def run_command(command) result = @server.ssh(command) result end |
#shutdown ⇒ Object
37 38 39 40 41 42 43 |
# File 'lib/zombees/worker.rb', line 37 def shutdown if @server && @server.ready? @server.destroy else logger.error "zombie bee is too badly damaged to get to the graveyard" end end |