Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

JavaExec does not exit properly when interrupted with container logging enabled and no output from a container #242

Open
tony-schellenberg opened this issue Jun 11, 2020 · 3 comments

Comments

@tony-schellenberg
Copy link

tony-schellenberg commented Jun 11, 2020

Long running JavaExec processes are left running when used with docker compose if the following happens:

  1. The process is long running
  2. The docker-compose stanza in gradle attempts to log the container output using one of
    • captureContainersOutput
    • captureContainersOutputToFile
  3. The container doesn't actually produce any output
    • Ran into this with the memcached container specifically

The following demonstrates the issue:

  1. Execute ./gradlew run to start
    • Web server that is long running
    • Has capture output statements in the docker-compose stanza
    • Uses memcached in the associated docker-compose file
  2. Inspect the process list
    • See that the process is running
  3. Interrupt gradle with ctrl-c
  4. Inspect the process list again
    • Notice that the process is still running
    • The process doesn't exit

Not sure how much of this is relevant but adding it in case it's useful:

  • O/S is Ubuntu 18.04
  • OpenJDK 11 from the O/S
  • Happens on the command line and when invoked with IntelliJ
  • Interestingly, doesn't seem to be an issue when gradle/the application is run in debug mode

I'm happy to provide more detail or information as required.

@augi augi added the question label Jun 12, 2020
@augi
Copy link
Member

augi commented Jun 12, 2020

Hello, unfortunately, there is no way (no API available) how to handle this situation with long-running processes correctly. You could execute Gradle with --no-daemon so the JVM should be turned off right after your build - then it should work as expected. This is actually the same as running in debug mode.

@tony-schellenberg
Copy link
Author

I just want to make sure my comment was clear. It's specifically an issue when the container does not produce any output and captureContainerOutput* is used in the docker-compose stanza. It works fine otherwise.

For example, if I switch from the memcached container to the mysql one (which does produce output), I can interrupt gradle and it will correctly shut down the main process.

@tony-schellenberg
Copy link
Author

Not sure if this is helpful but here's a small demo project with a readme that goes through the steps.
demo.tar.gz

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants