我正在尝试一次运行两个脚本concurrently
。基本命令如下所示:
concurrently -k --success first "node ./tools/mock-webapi/mock-webapi.js" "npm run test-single-run"
依次调用(本地):
"test-single-run": "karma start --single-run --browsers ChromeHeadless"
或在远程(teamcity 主机)上:
"test-teamcity": "karma start --reporters teamcity --single-run --browsers ChromeHeadless",
测试运行良好(本地和远程)。但是,我不断收到退出代码 1。即使我使用concurrently -k --success first
,我仍然会得到一个code 1
与--success first
.
[1] 09 05 2018 17:56:54.032:WARN [launcher]: ChromeHeadless was not killed in 2000 ms, sending SIGKILL.
[1] npm run test-single-run exited with code 0
--> Sending SIGTERM to other processes..
[0] node ./tools/mock-webapi/mock-webapi.js exited with code 1
我尝试了各种方法json-server
来优雅地接收这个信号。似乎没有任何效果。
模拟 webapi.js
process.on('SIGTERM', function (code) {
console.log('Handle SIGTERM', process.pid, code);
exitCode = 0;
server.close(function () {
process.exit(0);
});
});
process.on('SIGKILL', function (code) {
console.log('SIGKILL received...', code);
exitCode = 0;
server.close(function () {
process.exit(0);
});
});
process.on('SIGINT', function (code) {
console.log('SIGINT received...', code);
exitCode = 0;
server.close(function () {
process.exit(0);
});
});