Class: Drydock::Monitor
- Inherits:
-
Object
- Object
- Drydock::Monitor
- Defined in:
- lib/drydocker.rb
Overview
Class to actually run the monitor and tests
Instance Attribute Summary collapse
-
#config ⇒ Object
Returns the value of attribute config.
Instance Method Summary collapse
- #clean_containers ⇒ Object
-
#initialize(config) ⇒ Monitor
constructor
A new instance of Monitor.
- #listen ⇒ Object
Constructor Details
#initialize(config) ⇒ Monitor
Returns a new instance of Monitor.
34 35 36 |
# File 'lib/drydocker.rb', line 34 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
32 33 34 |
# File 'lib/drydocker.rb', line 32 def config @config end |
Instance Method Details
#clean_containers ⇒ Object
46 47 48 49 50 51 |
# File 'lib/drydocker.rb', line 46 def clean_containers fail 'No docker found' if File.which('docker').nil? return unless system("docker ps | grep #{config.name}") `docker kill #{config.name}` `docker rm #{config.name}` end |
#listen ⇒ Object
38 39 40 41 42 43 44 |
# File 'lib/drydocker.rb', line 38 def listen listener = Listen.to(config.path) do |modified, added, removed| puts "triggering change: #{modified + added + removed}" run_or_start end listener.start # not blocking end |