keithwhor / nodal

API Services Made Easy With Node.js
http://www.nodaljs.com/
MIT License
4.51k stars 209 forks source link

'nodal s' crashes when unrelated subdirectory is deleted #263

Closed dandee closed 8 years ago

dandee commented 8 years ago

I've got a project where nodal serves as API (pure) provider and a UI is generated separately using Grunt. Anyway, inside project's directory structure a 'build' dir is created while building UI side of the project. When you run rebuild command (or watch command that calls rebuild) then the content inside 'build' dir is removed and recreated from scratch. And this trips up 'nodal s' server running in the background with the following error:

[Nodal.98903] Ready: HTTP Worker listening on port 59000
[Nodal.Daemon] Shutdown: Exited with code 1
/projects/x/node_modules/fxn/core/required/daemon.js:0

Error: ENOENT: no such file or directory, scandir '/projects/x/build/ui/app'
    at Error (native)
    at Object.fs.readdirSync (fs.js:945:18)
    at /projects/x/node_modules/fxn/core/required/daemon.js:228:26
    at Array.forEach (native)
    at Timeout._repeat (/projects/x/node_modules/fxn/core/required/daemon.js:225:43)
    at Timeout.wrapper [as _onTimeout] (timers.js:417:11)
    at tryOnTimeout (timers.js:224:11)
    at Timer.listOnTimeout (timers.js:198:5)
[Nodal.98904] Shutdown: Exited with code 0
[Nodal.98902] Shutdown: Exited with code 0
[Nodal.98901] Shutdown: Exited with code 0
[Nodal.98903] Shutdown: Exited with code 0
[Nodal.98899] Shutdown: Exited with code 0
[Nodal.98900] Shutdown: Exited with code 0
[Nodal.98898] Shutdown: Exited with code 0
[Nodal.98896] Shutdown: Exited with code 0
[Nodal.98897] Shutdown: Exited with code 0
[Nodal.98894] Shutdown: Exited with code 0
▀ ╢░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░░╟
[Nodal.98895] Shutdown: Exited with code 0

npm ERR! Darwin 15.5.0
npm ERR! argv "/usr/local/Cellar/node/6.2.1/bin/node" "/usr/local/bin/npm" "start"
npm ERR! node v6.2.1
npm ERR! npm  v3.9.3
npm ERR! code ELIFECYCLE
npm ERR! x@0.0.1 start: `node cluster.js`
npm ERR! Exit status 1
npm ERR!
npm ERR! Failed at the x@0.0.1 start script 'node cluster.js'.
npm ERR! Make sure you have the latest version of node.js and npm installed.
npm ERR! If you do, this is most likely a problem with the x package,
npm ERR! not with npm itself.
npm ERR! Tell the author that this fails on your system:
npm ERR!     node cluster.js
npm ERR! You can get information on how to open an issue for this project with:
npm ERR!     npm bugs x
npm ERR! Or if that isn't available, you can get their info via:
npm ERR!     npm owner ls x
npm ERR! There is likely additional logging output above.

npm ERR! Please include the following file with any support request:
npm ERR!     /projects/x/npm-debug.log

Project's directory structure under /project/x/ is roughly following:

./app
    controllers
    models
./build <---- unrelated to remaining Nodal app.
./config
./db
    migrations
./middleware
./renderware
./schedulers
./tasks
./test
./ui <---- also not related to Nodal

npm-debug.log contains:

0 info it worked if it ends with ok
1 verbose cli [ '/usr/local/Cellar/node/6.2.1/bin/node',
1 verbose cli   '/usr/local/bin/npm',
1 verbose cli   'start' ]
2 info using npm@3.9.3
3 info using node@v6.2.1
4 verbose run-script [ 'prestart', 'start', 'poststart' ]
5 info lifecycle x@0.0.1~prestart: x@0.0.1
6 silly lifecycle x@0.0.1~prestart: no script for prestart, continuing
7 info lifecycle x@0.0.1~start: x@0.0.1
8 verbose lifecycle x@0.0.1~start: unsafe-perm in lifecycle true
9 verbose lifecycle x@0.0.1~start: PATH: /usr/local/lib/node_modules/npm/bin/node-gyp-bin:/projects/x/node_modules/.bin:/usr/local/Cellar/node/6.2.1/bin:/home/johndoe/bin:/home/johndoe/bin:/home/johndoe/bin:/usr/local/bin:/usr/local/sbin:/usr/bin:/bin:/usr/sbin:/sbin::/home/johndoe/.cask/bin:/home/johndoe/npm/bin:/usr/local/opt/go/libexec/bin::/home/johndoe/.cask/bin:/home/johndoe/npm/bin:/usr/local/opt/go/libexec/bin::/home/johndoe/.cask/bin:/home/johndoe/npm/bin:/usr/local/opt/go/libexec/bin
10 verbose lifecycle x@0.0.1~start: CWD: /projects/x
11 silly lifecycle x@0.0.1~start: Args: [ '-c', 'node cluster.js' ]
12 silly lifecycle x@0.0.1~start: Returned: code: 1  signal: null
13 info lifecycle x@0.0.1~start: Failed to exec start script
14 verbose stack Error: x@0.0.1 start: `node cluster.js`
14 verbose stack Exit status 1
14 verbose stack     at EventEmitter.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/lifecycle.js:245:16)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at EventEmitter.emit (events.js:191:7)
14 verbose stack     at ChildProcess.<anonymous> (/usr/local/lib/node_modules/npm/lib/utils/spawn.js:24:14)
14 verbose stack     at emitTwo (events.js:106:13)
14 verbose stack     at ChildProcess.emit (events.js:191:7)
14 verbose stack     at maybeClose (internal/child_process.js:852:16)
14 verbose stack     at Process.ChildProcess._handle.onexit (internal/child_process.js:215:5)
15 verbose pkgid x@0.0.1
16 verbose cwd /projects/x
17 error Darwin 15.5.0
18 error argv "/usr/local/Cellar/node/6.2.1/bin/node" "/usr/local/bin/npm" "start"
19 error node v6.2.1
20 error npm  v3.9.3
21 error code ELIFECYCLE
22 error x@0.0.1 start: `node cluster.js`
22 error Exit status 1
23 error Failed at the x@0.0.1 start script 'node cluster.js'.
23 error Make sure you have the latest version of node.js and npm installed.
23 error If you do, this is most likely a problem with the x package,
23 error not with npm itself.
23 error Tell the author that this fails on your system:
23 error     node cluster.js
23 error You can get information on how to open an issue for this project with:
23 error     npm bugs x
23 error Or if that isn't available, you can get their info via:
23 error     npm owner ls x
23 error There is likely additional logging output above.
24 verbose exit [ 1, true ]

Launching 'nodal s' seems to be watching EVERYTHING in ./. I think there should be way to handle the exception gracefully OR create a folder exclusion list in some config file.

keithwhor commented 8 years ago

My general recommendation is that you separate your front-end and back-end Nodal API into two separate projects. Might seem like a pain in the butt now, but we'll be offering a really seamless API deployment solution soon.