Module: Ey::Core::Cli::Helpers::LogStreaming

Included in:
Deploy, Status
Defined in:
lib/ey-core/cli/helpers/log_streaming.rb

Instance Method Summary collapse

Instance Method Details

#finished_request(request) ⇒ Object



20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
# File 'lib/ey-core/cli/helpers/log_streaming.rb', line 20

def finished_request(request)
  if request.successful
    if request.resource.successful
      puts "Deploy successful!".green
    else
      puts "Deploy failed!".red
    end
  else
    abort <<-EOF
        Deploy failed!
        Request output:
        #{request.message}
    EOF
    .red
  end
end

#stream_deploy_log(request) ⇒ Object



7
8
9
10
11
12
13
14
15
16
17
18
# File 'lib/ey-core/cli/helpers/log_streaming.rb', line 7

def stream_deploy_log(request)
  if request.finished_at
    return finished_request(request)
  end
  unless request.read_channel
    puts "Unable to stream log (streaming not enabled for this deploy)".yellow
    return
  end
  request.subscribe { |m| print m["message"] if m.is_a?(Hash) }
  puts "" # fix console output from stream
  finished_request(request)
end