<commit_before>require_relative 'Worker/worker'
require_relative 'killabeez'
ENV['DOCKER_URL'] = 'unix:///var/run/docker.sock'
require 'docker'
require 'git'

class DockerWorker < Worker
    include Resque::Plugins::Status
    @queue = "docker"
    def perform
      at(0, 3, "Cloning Repo")
      url = options['url']
      repo = options['repo']
      path = "/tmp/#{repo}"
      Worker.system_quietly("rm -rf #{path}")
      Git.clone(url, path)
      at(1, 3, "Building container")
      image = Docker::Image.build_from_dir(path)
      #container = image.run()
      Worker.system_quietly("docker -d -p 0.0.0.0:4567:4567 #{image.id}")
      puts ("docker run -d -p 0.0.0.0:4567:4567 #{image.id}")
      job_id = KillaBeez.create(:url => 'http://192.168.3.11:4567/test')
      while status = Resque::Plugins::Status::Hash.get(job_id) and !status.completed? && !status.failed?
        sleep 3
        puts status.inspect
      end
      at(2, 3, "Cleaning repo")
      Worker.system_quietly("rm -rf #{path}")
      puts "Container built"
    end
end<commit_msg>try waiting for build to complete<commit_after>require_relative 'Worker/worker'
require_relative 'killabeez'
ENV['DOCKER_URL'] = 'unix:///var/run/docker.sock'
require 'docker'
require 'git'

class DockerWorker < Worker
    include Resque::Plugins::Status
    @queue = "docker"
    def perform
      at(0, 3, "Cloning Repo")
      url = options['url']
      repo = options['repo']
      path = "/tmp/#{repo}"
      Worker.system_quietly("rm -rf #{path}")
      Git.clone(url, path)
      at(1, 3, "Building container")
      image = Docker::Image.build_from_dir(path)
      sleep(5)
      #container = image.run()
      Worker.system_quietly("docker -d -p 0.0.0.0:4567:4567 #{image.id}")
      puts ("docker run -d -p 0.0.0.0:4567:4567 #{image.id}")
      job_id = KillaBeez.create(:url => 'http://192.168.3.11:4567/test')
      while status = Resque::Plugins::Status::Hash.get(job_id) and !status.completed? && !status.failed?
        sleep 3
        puts status.inspect
      end
      at(2, 3, "Cleaning repo")
      Worker.system_quietly("rm -rf #{path}")
      puts "Container built"
    end
end
{'fraction_non_alphanumeric': 0.1608876560332871, 'fraction_numerical': 0.041146555709662504, 'mean_word_length': 2.9706422018348624, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 6, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '3991763', 'n_tokens_mistral': 824, 'n_tokens_neox': 765, 'n_words': 165}