lib/roku_builder/monitor.rb in roku_builder-3.3.3 vs lib/roku_builder/monitor.rb in roku_builder-3.3.4
- old
+ new
@@ -15,40 +15,43 @@
}
end
# Monitor a development log on the Roku device
# @param type [Symbol] The log type to monitor
- # @param verbose [Boolean] Print status messages.
def monitor(type:)
telnet_config = {
'Host' => @roku_ip_address,
'Port' => @ports[type]
}
waitfor_config = {
'Match' => /./,
'Timeout' => false
}
- thread = Thread.new(telnet_config, waitfor_config) {|telnet_config,waitfor_config|
- @logger.info "Monitoring #{type} console(#{telnet_config['Port']}) on #{telnet_config['Host'] }"
- connection = Net::Telnet.new(telnet_config)
+ thread = Thread.new(telnet_config, waitfor_config) {|telnet,waitfor|
+ @logger.info "Monitoring #{type} console(#{telnet['Port']}) on #{telnet['Host'] }"
+ connection = Net::Telnet.new(telnet)
Thread.current[:connection] = connection
all_text = ""
while true
- connection.waitfor(waitfor_config) do |txt|
+ connection.waitfor(waitfor) do |txt|
all_text = manage_text(all_text: all_text, txt: txt)
end
end
}
running = true
while running
- @logger.info "Q to exit"
- command = gets.chomp
- if command == "q"
- thread.exit
- running = false
- else
- thread[:connection].puts(command)
+ begin
+ @logger.info "Q to exit"
+ command = gets.chomp
+ if command == "q"
+ thread.exit
+ running = false
+ else
+ thread[:connection].puts(command)
+ end
+ rescue SystemExit, Interrupt
+ thread[:connection].puts("\C-c")
end
end
end
private