Skip to content

Commit 38448bf

Browse files
committed
add comments clarifying how the container output capturing works
1 parent 5e5fffc commit 38448bf

File tree

1 file changed

+4
-0
lines changed

1 file changed

+4
-0
lines changed

src/main/groovy/com/avast/gradle/dockercompose/tasks/ComposeUp.groovy

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -57,6 +57,8 @@ class ComposeUp extends DefaultTask {
5757
}
5858

5959
protected void captureContainersOutput() {
60+
// execute daemon thread that executes `docker-compose logs -f --no-color`
61+
// the -f arguments means `follow` and so this command ends when docker-compose finishes
6062
def t = Executors.defaultThreadFactory().newThread(new Runnable() {
6163
@Override
6264
void run() {
@@ -66,8 +68,10 @@ class ComposeUp extends DefaultTask {
6668
def buffer = new ArrayList<Byte>()
6769
@Override
6870
void write(int b) throws IOException {
71+
// store bytes into buffer until end-of-line character is detected
6972
if (b == 10 || b == 13) {
7073
if (buffer.size() > 0) {
74+
// convert the byte buffer to characters and print these characters
7175
def toPrint = buffer.collect { it as byte }.toArray() as byte[]
7276
logger.lifecycle(new String(toPrint))
7377
buffer.clear()

0 commit comments

Comments
 (0)