commands/docker-logs: parallelize for multiple containers
This commit is contained in:
parent
2add94ee28
commit
cb95e8aaee
|
@ -30,13 +30,11 @@ module VagrantPlugins
|
||||||
argv = parse_options(opts)
|
argv = parse_options(opts)
|
||||||
return if !argv
|
return if !argv
|
||||||
|
|
||||||
output_options = {}
|
|
||||||
output_options[:prefix] = false if !options[:prefix]
|
|
||||||
|
|
||||||
# TODO: exit with exit status != 0 if all machines are unknown
|
# TODO: exit with exit status != 0 if all machines are unknown
|
||||||
# or not created.
|
# or not created.
|
||||||
|
|
||||||
# Go through each machine and execute the client on it
|
# Go through each machine and execute the client on it
|
||||||
|
@env.batch do |batch|
|
||||||
with_target_vms(argv) do |machine|
|
with_target_vms(argv) do |machine|
|
||||||
if machine.provider_name != :docker
|
if machine.provider_name != :docker
|
||||||
machine.ui.output(I18n.t("docker_provider.not_docker_provder"))
|
machine.ui.output(I18n.t("docker_provider.not_docker_provder"))
|
||||||
|
@ -52,10 +50,21 @@ module VagrantPlugins
|
||||||
next
|
next
|
||||||
end
|
end
|
||||||
|
|
||||||
|
batch.custom(machine) do |m|
|
||||||
|
execute_single(m, options)
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
end
|
||||||
|
|
||||||
|
def execute_single(machine, options)
|
||||||
command = ["docker", "logs"]
|
command = ["docker", "logs"]
|
||||||
command << "--follow" if options[:follow]
|
command << "--follow" if options[:follow]
|
||||||
command << machine.id
|
command << machine.id
|
||||||
|
|
||||||
|
output_options = {}
|
||||||
|
output_options[:prefix] = false if !options[:prefix]
|
||||||
|
|
||||||
data_acc = ""
|
data_acc = ""
|
||||||
machine.provider.driver.execute(*command) do |type, data|
|
machine.provider.driver.execute(*command) do |type, data|
|
||||||
# Accumulate the data so we only output lines at a time
|
# Accumulate the data so we only output lines at a time
|
||||||
|
@ -84,5 +93,4 @@ module VagrantPlugins
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
end
|
||||||
end
|
|
||||||
end
|
end
|
||||||
|
|
Loading…
Reference in New Issue