gradle-node-plugin icon indicating copy to clipboard operation
gradle-node-plugin copied to clipboard

CTRL+C does not kill underlying nodejs server

Open Globegitter opened this issue 5 years ago • 4 comments

I am having a simple app created with https://github.com/facebook/create-react-app that I am using with this plugin. To start it I am running gradle yarn_run_start which starts a nodejs dev server with hot module reload etc. That all works fine, but when I exit out of it via CTRL+C and then later start the server again it reproducibly complains that the port is still open, i.e. the server was not killed through CTRL+C - I suppose SIGINT is not propagated correctly? Is there a way to make sure this happens?

Globegitter avatar Jul 01 '19 05:07 Globegitter

Any ideas? i can work on a solution but i dont know where to start looking.

nahue avatar Oct 01 '19 20:10 nahue

May just be a generic gradle issue with no good solution (other than maybe using --no-daemon flag) https://discuss.gradle.org/t/exec-task-and-killing-processes/6189 a docker plugin has same issue as well https://github.com/gradle/gradle/issues/8025

mmayer1 avatar Oct 03 '19 01:10 mmayer1

Indeed.. adding --no-daemon solves the issue. It seems that the node server thread is managed by the gradle daemon.. and stopping the task is not enough to kill it

nahue avatar Oct 03 '19 01:10 nahue

I've got a similar issue in Java - shutdownhook isn't called

https://stackoverflow.com/questions/64195246/how-to-send-ctrlc-sigint-signal-to-gradle-javaexec-task-type-forked-jvm

rsampaths16 avatar Dec 03 '21 11:12 rsampaths16