Method: Webbynode::Ssh#logs

Defined in:
lib/webbynode/ssh.rb

#logs(app_name) ⇒ Object



36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
# File 'lib/webbynode/ssh.rb', line 36

def logs(app_name)
  connect
  ch = @conn.open_channel do |ssh|
    ch.request_pty
    ch.exec "cd #{app_name}; tail -f log/production.log" do |ch, success|
      abort "Could not connect to rails app" unless success

      ch.on_data          { |ch, data| puts data}
      ch.on_extended_data { |ch, type, data| puts data }
    end

    @conn.loop
  end
    
  begin
    ch.wait
  rescue SystemExit, Interrupt
    ch.send_data(Net::SSH::Connection::Term::VINTR)
    
    puts ""
    puts ""
    puts "Logging done."
  rescue Exception => e
  end
end