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

Node process not stopped

Open jameskleeh opened this issue 9 years ago • 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?

jameskleeh avatar Sep 16 '16 15:09 jameskleeh

@srs Are you still interested in maintaining this plugin?

jameskleeh avatar Sep 27 '16 15:09 jameskleeh

I noticed someone had a similar problem and fixed it on a fork: https://github.com/laurimak/gradle-node-plugin/commit/2505514dde2d7005f9ef522b01574ac708ff5919

https://github.com/srs/gradle-gulp-plugin/issues/1

jameskleeh avatar Sep 27 '16 15:09 jameskleeh

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 avatar Sep 27 '16 19:09 srs

@srs The code seems to have changed significantly since that fork was made. Could you take a look and attempt to apply it?

jameskleeh avatar Sep 27 '16 19:09 jameskleeh

Yes, will do.

srs avatar Sep 28 '16 06:09 srs

I have the same issues while running angular-cli via YarnTask from gradle

After killing gradle with CTRL+C angular-cli is still running

kucharzyk avatar Jan 04 '17 17:01 kucharzyk

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

kucharzyk avatar Jan 04 '17 21:01 kucharzyk

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.

jinwangchina avatar Feb 01 '17 00:02 jinwangchina

I have the same problem... A solution would be very great @srs :/

drakenfly avatar Feb 04 '17 13:02 drakenfly

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.

slively avatar May 31 '17 17:05 slively

Adding org.gradle.daemon=false in gradle.properties does not work for me. I use --no-daemon option instead:

gradle --no-daemon

yohanesgultom avatar Sep 11 '17 03:09 yohanesgultom

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.

KIC avatar Dec 29 '17 14:12 KIC

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']
}

rlovtangen avatar May 03 '18 09:05 rlovtangen