open-cli-tools / concurrently

Run commands concurrently. Like `npm run watch-js & npm run watch-less` but better.
https://www.npmjs.com/package/concurrently
MIT License
7.15k stars 233 forks source link

on sending --kill-others process ng serve close with exit code 1 - STILL HAVE A ISSUE =) #484

Closed ramialkheshan closed 5 months ago

ramialkheshan commented 5 months ago

Hello! I have the next problem and this is my steps for reproduce: 1) I have main package.json where

"scripts": {
    "ng": "ng",
    "start": "ng serve",
    "stop": "taskkill -f -im node* && exit 0",
    "start4tests": "node ./src/scripts/runNgServeForTests.ts",
    "build": "ng build",
    "**test:integration**": "concurrently --kill-others --kill-signal SIGKILL --success all \"npm run start4tests\" \"wait-on http://localhost:4200/ && cd ./tests/wdio && npm install && npm run test:integration\"",

2) On my another package.json on test project I have this:

"test:integration": "cross-env TT_ENV=LOCAL wdio run ./config/wdio.integration.conf.ts",

3) In file ./src/scripts/runNgServeForTests.ts I have next code:

const { spawn } = require('child_process');

const ngServe = spawn('ng', ['serve', '--configuration=test'], { shell: true });

process.on('SIGINT', () => {
  console.log('SIGINT signal received. Shutting down gracefully...');
  ngServe.kill('SIGINT');
  process.exit(0);
});

ngServe.on('close', () => {
  process.exit(0);
});

And After running command /npm run test:integration

I got next result in my terminal

image

By the way I have tested without --kill-signal SIGKILL and result was the same

Could you help me understand how I can close ng serve process with exited code 0 ?

I was using --success flag with value all, but still have a issue

gustavohenke commented 5 months ago

I've replied in the other thread, you just need to look at the description of --success.

Basically, --kill-others will, well, kill the pending processes. Unless they handle the SIGTERM signal (SIGKILL can't be handled), you need to change from --success all to some other value to pick which other process(es) you want the success result to come from. You can't have --success all when one of your processes is exiting with code 1.

ramialkheshan commented 5 months ago

I've replied in the other thread, you just need to look at the description of --success.

Basically, --kill-others will, well, kill the pending processes. Unless they handle the SIGTERM signal (SIGKILL can't be handled), you need to change from --success all to some other value to pick which other process(es) you want the success result to come from. You can't have --success all when one of your processes is exiting with code 1.

I have tried, but still have exited code 1 again

gustavohenke commented 5 months ago

...and what did you try?