Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix tailing #52

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
15 changes: 8 additions & 7 deletions lib/stemcell/command_line.rb
Original file line number Diff line number Diff line change
Expand Up @@ -95,14 +95,15 @@ def launch_instance(role, options={})
def tail_converge(instances, options={})
puts "\nTailing the initial converge. Press Ctrl-C to exit...".green

if instances.count > 1
puts "\nYou're launching more than one instance."
puts "Showing you on the output from #{instances.first.instance_id}."
end

puts "\n"
tailer = LogTailer.new(instances.first.public_dns_name, options['ssh_user'])
tailer.run!
tailing_threads = instances.map do |instance|
Thread.new do
tailer = LogTailer.new(instance.public_dns_name, options['ssh_user'])
tailer.run!
puts "Finished #{instance.public_dns_name} => #{instance.id}"
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yay, having the instance id at the end would be so useful.

end
end
tailing_threads.each(&:join)
end

def retrieve_defaults
Expand Down
14 changes: 11 additions & 3 deletions lib/stemcell/log_tailer.rb
Original file line number Diff line number Diff line change
Expand Up @@ -77,14 +77,22 @@ def wait_for_ssh
end

puts " UP!".green
puts "Server responded with: #{banner.green}"
puts "Server responded with: #{banner.strip.green}"
true
end

def tail_until_interrupt
return if interrupted

session = Net::SSH.start(hostname, username)
print "Starting connection "
begin
session = Net::SSH.start(hostname, username)
rescue Net::SSH::AuthenticationFailed
print "."
sleep 5
retry
end
puts " STARTED!".green

channel = session.open_channel do |ch|
ch.request_pty do |ch, success|
Expand Down Expand Up @@ -137,7 +145,7 @@ def while_catching_interrupt
trap(:SIGINT) { @interrupted = true }
yield
ensure
trap(:SIGINT, nil)
trap(:SIGINT, nil)
end
end
end