Class: Drydocker::Monitor
- Inherits:
-
Object
- Object
- Drydocker::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
- #run_or_start ⇒ Object
Constructor Details
#initialize(config) ⇒ Monitor
Returns a new instance of Monitor.
44 45 46 |
# File 'lib/drydocker.rb', line 44 def initialize(config) @config = config end |
Instance Attribute Details
#config ⇒ Object
Returns the value of attribute config.
42 43 44 |
# File 'lib/drydocker.rb', line 42 def config @config end |
Instance Method Details
#clean_containers ⇒ Object
58 59 60 61 62 63 64 |
# File 'lib/drydocker.rb', line 58 def clean_containers fail "No docker found" if File.which("docker").nil? return unless system(docker_check_cmd) config.logger.debug("cleaning up previous containers") `docker kill #{config.name}` `docker rm #{config.name}` end |
#listen ⇒ Object
48 49 50 51 52 53 54 55 56 |
# File 'lib/drydocker.rb', line 48 def listen run_or_start listener = Listen.to(config.path) do |modified, added, removed| config.logger.info("triggering change: #{modified + added + removed}") run_or_start end listener.start # not blocking config.logger.info("now listening") end |
#run_or_start ⇒ Object
66 67 68 |
# File 'lib/drydocker.rb', line 66 def run_or_start system(docker_check_cmd) ? start : run end |