Class: MKIt::DockerListener

Inherits:
Object
  • Object
show all
Includes:
DockerHelper
Defined in:
lib/mkit/pods/docker_listener.rb

Instance Method Summary collapse

Methods included from DockerHelper

#attach_network, #create_instance, #create_network, #create_volume, #delete_volume, #dettach_network, #execute_local, #inspect_instance, #inspect_volume, #logs, #network_exists?, #remove_instance, #remove_network, #start_instance, #stop_instance

Constructor Details

#initializeDockerListener

Returns a new instance of DockerListener.



14
15
16
17
# File 'lib/mkit/pods/docker_listener.rb', line 14

def initialize
  @queue = Queue.new
  @listener = ShellClient.new(command: "docker events --format '{{json .}}'")
end

Instance Method Details

#enqueue(msg) ⇒ Object



19
20
21
# File 'lib/mkit/pods/docker_listener.rb', line 19

def enqueue(msg)
  @queue << msg
end

#startObject



23
24
25
26
# File 'lib/mkit/pods/docker_listener.rb', line 23

def start
  @consumer.run if register_consumer
  register_listener
end

#stopObject



28
29
30
31
32
# File 'lib/mkit/pods/docker_listener.rb', line 28

def stop
  @listener.unregister if @listener
  @consumer.raise StopThread.new
  MKItLogger.info("docker listener stopped")
end