问题
I am starting multiple npm tasks in parallel (using &
, not just in sequence &&
). Thus in package.json:
"start": "npm run watch-blog & npm run watch-data & npm run server",
And those sub-tasks are useful stuff to me like:
"watch-blog" : "watchy -w _posts/**/* -- touch _pages/blog.md",
Question: How can I all shut down all three tasks together?
I noticed CTRL–C is only killing the last. (my watch-blog survives and keeps „touching“)
Closing the terminal window doesn't help. Only killall node
does the job, but that's killing more than I would like to…
回答1:
Killing detached processes (that's the word…) will be a pain. One will have to look at pids, and more stuff coming your way. Not to mention cross-platform issues, if meant to work under windows...
Easier and working:
npm install concurrently --save
and thus
"start": "concurrently \"npm run watch-blog\" \"npm run watch-data\" \"npm run serve\"",
Tested (under Ubuntu 16.04, npm 5.6).
来源:https://stackoverflow.com/questions/49725593/stop-all-processes-depending-on-npm-start