Class: Stemcell::LogTailer

Inherits:
Object
  • Object
show all
Defined in:
lib/stemcell/log_tailer.rb

Constant Summary collapse

MAX_WAIT_FOR_SSH =

Don’t wait more than two minutes

120
TAILING_COMMAND =
"while [ ! -s /var/log/init ]; " \
"do " \
  "printf '.' 1>&2; " \
  "sleep 1; " \
"done; " \
"echo ' /var/log/init exists!' 1>&2; " \
"exec tail -qf /var/log/init*"

Instance Attribute Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(hostname, username, ssh_port = 22) ⇒ LogTailer

Returns a new instance of LogTailer.



25
26
27
28
29
30
31
32
# File 'lib/stemcell/log_tailer.rb', line 25

def initialize(hostname, username, ssh_port=22)
  @hostname = hostname
  @username = username
  @ssh_port = ssh_port

  @finished = false
  @interrupted = false
end

Instance Attribute Details

#finishedObject (readonly)

Returns the value of attribute finished.



10
11
12
# File 'lib/stemcell/log_tailer.rb', line 10

def finished
  @finished
end

#hostnameObject (readonly)

Returns the value of attribute hostname.



6
7
8
# File 'lib/stemcell/log_tailer.rb', line 6

def hostname
  @hostname
end

#interruptedObject (readonly)

Returns the value of attribute interrupted.



11
12
13
# File 'lib/stemcell/log_tailer.rb', line 11

def interrupted
  @interrupted
end

#ssh_portObject (readonly)

Returns the value of attribute ssh_port.



8
9
10
# File 'lib/stemcell/log_tailer.rb', line 8

def ssh_port
  @ssh_port
end

#usernameObject (readonly)

Returns the value of attribute username.



7
8
9
# File 'lib/stemcell/log_tailer.rb', line 7

def username
  @username
end

Instance Method Details

#run!Object



34
35
36
37
38
39
# File 'lib/stemcell/log_tailer.rb', line 34

def run!
  while_catching_interrupt do
    return unless wait_for_ssh
    tail_until_interrupt
  end
end