bin/matrix in kommando-0.1.0 vs bin/matrix in kommando-0.1.1

- old
+ new

@@ -1,9 +1,14 @@ #!/usr/bin/env ruby require "./lib/kommando" require "yaml" +loops=if ARGV[0] + ARGV[0].to_i +else + -1 +end docker_compose=YAML.load(File.read("docker-compose.yml")) services = docker_compose["services"].keys Kommando.run("docker-compose build", { @@ -17,19 +22,33 @@ k = Kommando.new "docker-compose up #{service}" k.run_async ks << k end +def cleanup(ks) + ks.map(&:kill) + Kommando.run "docker-compose down" +end + loop do + puts "loops: #{loops}" + loops = loops - 1 + for k in ks do cmd=k.instance_variable_get(:@cmd) puts "#{cmd} (#{(k.code ? "STOP" : "RUNNING")})" if k.code puts k.out + cleanup(ks) exit 1 end end print "-"*20; puts " #{DateTime.now.to_s}" sleep 2 + + if loops == 0 + cleanup(ks) + exit 0 + end end