GoogleCloudPlatform / cloud-run-button

Let anyone deploy your GitHub repos to Google Cloud Run with a single click
https://cloud.run
Apache License 2.0
525 stars 91 forks source link

Strange STDOUT Issue With Hooks #201

Open jamesward opened 3 years ago

jamesward commented 3 years ago

Reproduce with: https://github.com/jamesward/springboot-kotlin-reactive-demo/tree/repro-stdout

When the build hook command runs it stops outputting after a few seconds, like:

[ ! ] Running command: ./gradlew --no-daemon --console=plain bootBuildImage --imageName=$IMAGE_URL
+ ./gradlew --no-daemon --console=plain bootBuildImage --imageName=gcr.io/jw-demo/springboot-kotlin-reactive-demo
Downloading https://services.gradle.org/distributions/gradle-6.7-bin.zip
.........10%!(NOVERB)

If I run the same command in Cloud Shell (not via Button) I get:

./gradlew --no-daemon --console=plain bootBuildImage --imageName=gcr.io/jw-de
mo/springboot-kotlin-reactive-demo
Downloading https://services.gradle.org/distributions/gradle-6.7-bin.zip
.........10%..........20%..........30%..........40%..........50%.........60%..........70%..........80%..........90%..........100
%
Welcome to Gradle 6.7!
...
ahmetb commented 3 years ago

I think that's basically gradlew (or whatever subprocess) not detecting that the STDOUT/STDERR is not a real TTY device, but continuing to print interactive progress and control characters.

A good way to test this is to run like command 2>&1 | tee file.txt, if you are still seeing the same output in the file.txt, then I think that program is not well-written to handle this case.

We could attach a pseudo-TTY to the commands, but it's less than ideal, as they could clear the screen etc.