Node process not stopped
jameskleeh opened this issue ยท 13 comments
I've configured a task to start a server to serve static assets:
task serve(type: NpmTask) {
group = 'application'
description = 'Serve the client side application'
args = ['run', 'start']
}
When I stop the gradle task, the node executable keeps running. What are my options to ensure the process gets shut down?
@srs Are you still interested in maintaining this plugin?
I noticed someone had a similar problem and fixed it on a fork: laurimak@2505514
Hi.
Yes, still maintaining it since I use it in a lot of projects. It would be great to have a pull-request of this fix ;-)
@srs The code seems to have changed significantly since that fork was made. Could you take a look and attempt to apply it?
Yes, will do.
I have the same issues while running angular-cli via YarnTask from gradle
After killing gradle with CTRL+C angular-cli is still running
I've found temporary solution.
Disabling gradle deamon fix this issue.
Just create following gradle.properties file in project directory
org.gradle.daemon=false
With deamon disabled everything works allright.
With deamon enabled some node tasks are still alive after terminating gradle task
hi @kucharzyk, seems your solution doesn't work to me, I use gradle to start webpack-dev-server, after stop the gradle task in Intellij, the webpack-dev-server is still working.
I was having the same issue from a create-react-app project when trying to run the webpack dev server through yarn.
task start(type: YarnTask) {
args = ['start']
}
What I saw was gradle would start a yarn process using project.exec and yarn would then start a node process (node script/start.js). When Gradle exited, the yarn process would exit, but the subsequent node process would stay around. I worked around this by just calling node directly using NodeTask
.
task start(type: NodeTask) {
script = file('scripts/start.js')
}
Now gradle only spawns a single node process and when gradle exits the node process exits (after a handful of seconds). This is certainly still an issue, but I've found this to be a very acceptable work around.
Adding org.gradle.daemon=false
in gradle.properties
does not work for me. I use --no-daemon
option instead:
gradle --no-daemon
alternatively you can still use the the deamon but use ./grawdlew --stop
to kill all gradle processes (note that this is a flag and not a task, so it is in fact --stop
. But it still takes a while until the node server is gone. You can check the status of the deamon by using ./gradlew --status
.
Tried different Gradle version. I'm having this issue with Gradle 3.2 and later (including 4.7, which is latest). Probably related to Ctrl-C changes described here: https://docs.gradle.org/3.2/release-notes.html#ctrl-c-no-longer-stops-the-daemon-on-first-run
Using --no-daemon
seems to work.
My build.gradle:
plugins {
id "com.moowork.node" version "1.2.0"
}
node {
version = '10.0.0'
yarnVersion = '1.6.0'
download = true
}
task start(type: YarnTask, dependsOn: 'yarn') {
group = 'application'
description = 'Run the client app'
args = ['run', 'start']
}