Skip to content

Commit

Permalink
Improve container alive detection
Browse files Browse the repository at this point in the history
  • Loading branch information
pocke committed Jan 13, 2019
1 parent 3dd8161 commit ef8d5ea
Showing 1 changed file with 10 additions and 3 deletions.
13 changes: 10 additions & 3 deletions tasks/integration_local_spec.rb
Expand Up @@ -37,12 +37,15 @@ def run

def docker_run
mount_dir = Pathname(__dir__).join('../').to_s
if container_alive?
raise "Docker container is already running. Please stop the container with `docker rm -f #{CONTAINER_NAME}`"
end

Thread.new do
Thread.current.abort_on_exception = true
sh 'docker', 'run', '--privileged', '--name', CONTAINER_NAME, '-v', "#{mount_dir}:/itamae", "ruby:#{@ruby_version}", 'sleep', '1d'
end
sleep 0.5 until `docker ps` =~ /itamae$/

sleep 0.5 until container_alive?
end

def prepare
Expand Down Expand Up @@ -76,4 +79,8 @@ def clean_docker_container
def docker_exec(*cmd, options: [])
sh 'docker', 'exec', '--env', 'LANG=en_US.utf8', *options, CONTAINER_NAME, *cmd
end

def container_alive?
`docker ps` =~ /itamae$/
end
end

0 comments on commit ef8d5ea

Please sign in to comment.