npm-run-all
npm-run-all copied to clipboard
Ctrl-C stops all processing, is there a way around?
I have my config set like the following:
"prestart:dev": "docker-compose -f devops/docker-compose.yaml up -d redis-cluster",
"run:dev": "rimraf dist; NODE_ENV=development nest start --watch",
"start:dev": "npm-run-all run:dev start:dev:teardown --continue-on-error",
"start:dev:teardown": "docker-compose -f devops/docker-compose.yaml stop redis-cluster && docker-compose -f devops/docker-compose.yaml rm -f redis-cluster",
When I run my code using npm run start:dev
it will create my docker in the prestart, call the npm-run-all which calls the run:dev. Since the node runs with --watch (or even without for that matter since node runs until canceled) when I stop it with ctrl-c it stops the whole process. the start:dev:teardown doesn't run at all.
I was able to get around it using kill -s TERM PID
, but that takes time to lookup the PID and run it in a second window. Is there some way to get the next item to still run after a ctrl-c is passed?
Have you solved this issue?
this package does not handle this case well, my guess is that it sends some super-kill signal. anyway, I got a similar setup to work (on mac/linux) using background jobs and npm pre-script:
"start:proxy": "docker-compose -f reverse-proxy/docker-compose.yml up",
"prestart": "yarn start:proxy &",
"start": "nx serve",
In my case I wanted the reverse-proxy container to stop when I abort the start command so I ran it without the -d