Class: MKIt::DockerLogListener
- Inherits:
-
ShellClient
- Object
- ShellClient
- MKIt::DockerLogListener
- Includes:
- DockerHelper
- 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 included from DockerHelper
#attach_network, #clear_logs, #create_instance, #create_network, #create_volume, #delete_volume, #dettach_network, #execute_local, #inspect_instance, #inspect_volume, #logfile, #logs, #network_exists?, #remove_instance, #remove_network, #start_instance, #stop_instance, #to_docker_cpu_limit
Methods inherited from ShellClient
Constructor Details
#initialize(pod, ws, options: {}) ⇒ DockerLogListener
Returns a new instance of DockerLogListener.
9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 |
# File 'lib/mkit/pods/docker_log_listener.rb', line 9 def initialize(pod, ws, options: {}) if [:clear] clear_logs(pod.name) end @pod = pod @ws = ws command = "docker logs" command += " -f" if [:follow] == 'true' command += " -n #{[:nr_lines]}" if [:nr_lines] command += " -n 10" unless [:nr_lines] command += " -t" if [:timestamps] == 'true' command += " --since #{[:since]}" if [:since] command += " --until #{[:until]}" if [:until] command += " --details" if [:details] == 'true' command += " #{@pod.name}" super(command: command) end |
Instance Method Details
#close ⇒ Object
35 36 37 |
# File 'lib/mkit/pods/docker_log_listener.rb', line 35 def close @ws.close_websocket unless @ws.nil? end |
#register ⇒ Object
27 28 29 30 31 32 33 |
# File 'lib/mkit/pods/docker_log_listener.rb', line 27 def register super do |stdout, stdin, pid| stdout.each { |line| @ws.send(line.strip!) } end end |