From 35ec2292bbb400afb7884e94a5fec05ab3340a06 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Michal=20August=C3=BDn?= Date: Wed, 3 Oct 2018 15:12:53 +0200 Subject: [PATCH] Allow tcp ignore for waiting (#169) option to ignore TCP ports when waiting --- README.md | 1 + .../com/avast/gradle/dockercompose/ComposeSettings.groovy | 1 + .../com/avast/gradle/dockercompose/tasks/ComposeUp.groovy | 4 +++- 3 files changed, 5 insertions(+), 1 deletion(-) diff --git a/README.md b/README.md index 0c1519e..b97d90b 100644 --- a/README.md +++ b/README.md @@ -88,6 +88,7 @@ dockerCompose { downAdditionalArgs = ['--some-switch'] waitForTcpPorts = true // turns off the waiting for exposed TCP ports opening + tcpPortsToIgnoreWhenWaiting = [1234] // list of TCP ports what will be ignored when waiting for exposed TCP ports opening; default: empty list captureContainersOutput = false // if true, prints output of all containers to Gradle output - very useful for debugging; default is false captureContainersOutputToFile = '/path/to/logFile' // sends output of all containers to a log file composeLogToFile = project.file('build/my-logs.txt') // redirect output of composeUp and composeDown tasks to this file; default is null (ouput is not redirected) diff --git a/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy b/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy index a3c6054..5349831 100644 --- a/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy +++ b/src/main/groovy/com/avast/gradle/dockercompose/ComposeSettings.groovy @@ -35,6 +35,7 @@ class ComposeSettings { boolean buildBeforeUp = true boolean buildBeforePull = true boolean waitForTcpPorts = true + List tcpPortsToIgnoreWhenWaiting = [] Duration waitAfterTcpProbeFailure = Duration.ofSeconds(1) Duration waitForTcpPortsTimeout = Duration.ofMinutes(15) Duration waitForTcpPortsDisconnectionProbeTimeout = Duration.ofMillis(1000) diff --git a/src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeUp.groovy b/src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeUp.groovy index d275fa7..add9529 100644 --- a/src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeUp.groovy +++ b/src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeUp.groovy @@ -157,7 +157,9 @@ class ComposeUp extends DefaultTask { def start = Instant.now() servicesInfos.forEach { serviceInfo -> serviceInfo.containerInfos.each { instanceName, containerInfo -> - containerInfo.tcpPorts.forEach { exposedPort, forwardedPort -> + containerInfo.tcpPorts + .findAll { ep, fp -> !settings.tcpPortsToIgnoreWhenWaiting.any { it == ep } } + .forEach { exposedPort, forwardedPort -> logger.lifecycle("Probing TCP socket on ${containerInfo.host}:${forwardedPort} of service '${instanceName}'") while (true) { try {