-
Notifications
You must be signed in to change notification settings - Fork 224
Description
SIGTERM code does not propagate well between layers
C:\Program Files (x86)\Nodist\bin\node.exe
drops the ball with SIGTERM signals.
After fiddling, here's a work around:
When I set my env. var PATH to skip nodist\bin\node.exe
it works as expected,
(i.e. path includes: C:\Program Files (x86)\Nodist;C:\Program Files (x86)\Nodist\bin;
)
where with the value provided by the installer - it does not work and the problem is reproduced.
(i.e. path includes only: C:\Program Files (x86)\Nodist\bin;
)
Full details bellow.
Osher
> nodist -v
0.8.4
windows 10.
I learnt that nodist
is built like onion, where a process spawns a process with many pipes between.
I'm not sure what's the role of each layer - but. here's the story:
I'm working on a code-generator for web-servers.
The generator expects an open-api spec-file, and generates:
a) a project that answer mock replies
b) test suite for the core parts
c) end-to-end test suite that the server passes with mock replies that meet the spec.
Then developers can enter the project and replace mocks with real logic, and keep tests passing.
And I code the generator with with bdd, so I have an end-to-end test for the generator itself, that:
-
use child_process.exec Run the generator with a given openapi-spec file
-
use child_process.exec Run the generated unit-tests
-
use child_process.exec to run the generated end-to-end tests in a mocha suite that:
3.1. use a before-all hook to lunch the server using
child = child_process.spawn('node', ['server.js'], { cwd: targetDir })
3.2. fire all the generated requests using request/request
3.3. use an after-all hook tochild.kill('SIGTERM')
and collect the logs it emits through it's well-handled graceful shutdown.
Then I noted that ever since I started to use nodist the server lunched for the generated end-to-end test in step 3.1 does not get the SIGTERM
command.
I wasted on it half a day trying to isolate the problem...
To make a long story short, I found the problem is based on the node-process that is started using the child_process.spawn comand.
When I used absolute paths to concrete node version distributables - the child process heard the SIGTERM, and all was dandy.
(i.e. - spawn(["c:\\node-dist\\node-v6.5.0-win-x64\\node.exe",...
)
But when I just used child_process.spawn('node'...
- the problem was reproduced.
I almost gave up on nodist and moved to use my own simple repository of node versions, but on the last moment I noted there's node.exe
in many places:
- nodist\bin\node.exe
- nodist\node.exe
- nodist\v-x64\node.exe
(Now I also assume that they call each other in this order)
So I decided to try absolute path to concrete version from the nodist\v-x64. and it worked.
(i.e. - spawn(["C:\\Program Files (x86)\\Nodist\\v-x64\\6.5.0\\node.exe",...
)
I tried absolute path to nodist\node.exe
- and it worked.
I tired absolute path to nodist\bin\node.exe
- and the problem was reproduced, the same way as it behaved when I spawn(["node", ...
.
I went to check my PATH variable.
I kept the code with spawn(["node", ...
- i.e. - let the OS seach for node
in %PATH%.
When I set my env. var PATH to skip nodist\bin\node.exe
it works,
(i.e. path includes: C:\Program Files (x86)\Nodist;C:\Program Files (x86)\Nodist\bin;
)
where with the value provided by the installer - the problem is reproduced.
(i.e. path includes only: C:\Program Files (x86)\Nodist\bin;
)