package.json
:
{
...
"scripts": {
"start": "node start.js"
}
}
start.js
:
require('nodemon');
setTimeout(() => {}, 1e6);
ํฐ๋ฏธ๋์์ :
# Does not print anything (except `grep` itself), i.e. no node process is running
$ ps aux | grep node
# We run the `start` task then interrupt it with CTRL-C
$ yarn start
yarn run v1.6.0
node start.js
^C
# yarn was killed, but not `start.js`
$ ps aux | grep node
me 4053 0.0 0.0 4608 876 pts/2 S 14:29 0:00 /bin/sh -c node start.js
me 4054 0.0 0.0 873592 28564 pts/2 Sl 14:29 0:00 node start.js
require('nodemon')
์ค์ด ์์ผ๋ฉด start.js
ํ๋ก์ธ์ค๊ฐ ์ค์ ์ํด ์ ๋๋ก ์ข
๋ฃ๋ฉ๋๋ค.
npm run
์์๋ ๋ฌธ์ ๊ฐ๋์ง ์์ต๋๋ค. https://github.com/yarnpkg/yarn/issues/4667 ๊ณผ ๊ด๋ จ์ด์์ ์ ์์ต๋๋ค (ํ์คํ์ง ์์)
ํ์ํ ๊ฒฝ์ฐ Nodemon์ SIGINT
์ด๋ฒคํธ ํธ๋ค๋ฌ๋ฅผ ์ค์นํฉ๋๋ค. ์ค์ด์ง๋ฉด CTRL-C
, ๊ทธ๊ฒ์ ์์ผ๋ก ๊ทธ๊ฒ์ script.js
์๊ธฐ ๋๋ฌธ์์ด ์๋ฌด๊ฒ๋ ์คํ SIGINT
์ด๋ฒคํธ ํธ๋ค๋ฌ๋ฅผ ๊ฐ์ง๊ณ ์๋ค.
์ด ์์ ๋ ๋ฌธ์ ๋ฅผ ์ ํํ ํ์ ํ๊ธฐ ์ํด ์ฝ๊ฐ ๊ณ ์๋์์ง๋ง ์ค์ ์๋๋ฆฌ์ค์์๋ ๋ค์๊ณผ ๊ฐ์ต๋๋ค.
setTimeout()
๋์ gulp.watch()
CTRL-C
์์ Gulp ๊ฐ์ ์์
์ด ์ข
๋ฃ๋์ง ์์ต๋๋ค.ํ ๊ฐ์ง ํด๊ฒฐ ๋ฐฉ๋ฒ์ Nodemon์ ์ธ์คํด์คํ ํ ๋๋ง ์กฐ๊ฑด๋ถ๋ก Nodemon์ ์๊ตฌํ๋ ๊ฒ์ด์ง๋ง ์ค์ ์๋ฃจ์ ์ด๋ผ๊ธฐ๋ณด๋ค๋ ํดํน์ฒ๋ผ ๋๊ปด์ง๋๋ค.
๋ฒ์ : Node.js 8.11.0, Nodemon 1.17.3, yarn 1.6.0, Ubuntu 17.10
๊ทธ๊ฒ์ _is_ yarn, ๋๋ yarn์ผ๋ก ๋ณต์ ํ ์ ์์ง๋ง npm์ผ๋ก๋ ๋ณต์ ํ ์ ์์ต๋๋ค.
_ํ์ง๋ง _ ๊ทธ๊ฒ์ ๋ํ nodemon ๋ด๋ถ์์๋ ๊ณ ์น ์์๋ ๊ฒ์ ๋๋ค. ๊ผญ ๋ถ์ก์.
์, PR์์ด ๋ฌธ์ ๋ฅผ ์ง์ ํด๊ฒฐํ๋ ๊ฒ ๊ฐ์ต๋๋ค! ๊ฐ์ฌํฉ๋๋ค. ๋น ๋ฅด ๋ค์!
@ehmicky ๋ ํน๋ณํ ๋น ๋ฅด์ง๋ ์์ต๋๋ค. ์์ด๋ค์๊ฒ ์ ๋ ์์ฌ๋ฅผํ๊ธฐ ์ ์
@remy ์๋ง๋ ๋ค๋ฅธ ๋ฌธ์ ์ธ์ง ํ์คํ์ง ์์ง๋ง ์ฌ์ ํ
nodemon
๋ก ํ๋ก์ธ์ค๋ฅผ ์ง์ ์คํํ๋ฉด ๋ฌธ์ ๊ฐ ์์ต๋๋ค. yarn
์คํํ๋ฉด ๋ฌธ์ ์์ต๋๋ค. yarn
์ nodemon
๋ฅผ ๊ฒฐํฉํ๋ฉด CTRL-C๋ฅผ ๋ ๋ฒ ๋๋ฌ์ผํ๋ ํ๋ก์ธ์ค๋ฅผ ์ข
๋ฃ ํ ์ ์์ต๋๋ค.
์์ธํ ๋ด์ฉ์ https://superuser.com/questions/1594660/why-does-zsh-keep-running-after-exiting-a-process-with-ctrl-c-until-ctrl ์์ SO ์ง๋ฌธ์ ๋ง๋ค์์ต๋๋ค.