Class: MKIt::DockerLogListener
- Inherits:
-
ShellClient
- Object
- ShellClient
- MKIt::DockerLogListener
- Defined in:
- lib/mkit/pods/docker_log_listener.rb
Instance Method Summary collapse
- #close ⇒ Object
-
#initialize(pod, ws, options: {}) ⇒ DockerLogListener
constructor
A new instance of DockerLogListener.
- #register ⇒ Object
Methods inherited from ShellClient
Constructor Details
#initialize(pod, ws, options: {}) ⇒ DockerLogListener
Returns a new instance of DockerLogListener.
6 7 8 9 10 11 12 13 14 15 |
# File 'lib/mkit/pods/docker_log_listener.rb', line 6 def initialize(pod, ws, options: {}) @pod = pod @ws = ws command = "docker logs" command += " -f" if [:follow] == 'true' command += " -n #{options[:nr_lines]}" if [:nr_lines] command += " -n 10" unless [:nr_lines] command += " #{@pod.name}" super(command: command) end |
Instance Method Details
#close ⇒ Object
25 26 27 |
# File 'lib/mkit/pods/docker_log_listener.rb', line 25 def close @ws.close_websocket unless @ws.nil? end |
#register ⇒ Object
17 18 19 20 21 22 23 |
# File 'lib/mkit/pods/docker_log_listener.rb', line 17 def register super do |stdout, stdin, pid| stdout.each { |line| @ws.send(line.strip!) } end end |