ci.gradle icon indicating copy to clipboard operation
ci.gradle copied to clipboard

libertyRun task does not really run Liberty in foreground

Open aguibert opened this issue 7 years ago • 2 comments
trafficstars

One of the key differences of ./server start and ./server run is that start runs the server in the background, and run runs the server in the foreground. Using the run option is convenient because it allows the user to CTRL+C in their shell to kill the server process without needing to issue a separate ./server stop command.

If I try ./gradlew libertyRun and do CTRL+C, it does not stop the server, because gradle runs all work on a daemon thread by default. However, even if I do ./gradlew libertyRun --no-daemon, the server does not stop when I CTRL+C the foreground process my my terminal window.

aguibert avatar Dec 15 '17 17:12 aguibert

libertyRun is a tricky problem. Similar issues have been posted to the Gradle forums (in regards to Spring) and it seems that Gradle acknowledges its clash in design with running foreground processes. Until they release a better solution to receiving a Ctrl-C or SIGINT, we'll have to stick with our current "incomplete" approach.

./gradlew libertyRun --no-daemon is likely a bug on our end however. Worst case, we'll have to add a redundant libertyStop in our shutdownHook. Are there any more steps you took to reproduce this bug? Could you also provide additional information about your work environment?

dshimo avatar Dec 18 '17 16:12 dshimo

No special steps or env to reproduce this bug -- it should happen all the time for libertyRun.

I agree that this is more of a gradle problem, but in the meantime ci.gradle should do its best to cope. Doing a stop in the shutdownHook would be the most "proper" solution, although I'm not sure if it's bad practice to have such a heavy-weight shutdownHook.

aguibert avatar Dec 18 '17 17:12 aguibert