cli: gracefully shut down child process on windows
Signed-off-by: Patrik Oldsberg <poldsberg@gmail.com>
This commit is contained in:
@@ -0,0 +1,5 @@
|
||||
---
|
||||
'@backstage/cli': patch
|
||||
---
|
||||
|
||||
Fixed an issue where the new backend start command would not gracefully shut down the backend process on Windows.
|
||||
@@ -78,6 +78,7 @@
|
||||
"cross-fetch": "^3.1.5",
|
||||
"cross-spawn": "^7.0.3",
|
||||
"css-loader": "^6.5.1",
|
||||
"ctrlc-windows": "^2.1.0",
|
||||
"diff": "^5.0.0",
|
||||
"esbuild": "^0.19.0",
|
||||
"esbuild-loader": "^2.18.0",
|
||||
|
||||
@@ -18,6 +18,7 @@ import { FSWatcher, watch } from 'chokidar';
|
||||
|
||||
import { BackendServeOptions } from '../bundler/types';
|
||||
import type { ChildProcess } from 'child_process';
|
||||
import { ctrlc } from 'ctrlc-windows';
|
||||
import { IpcServer } from './IpcServer';
|
||||
import { ServerDataStore } from './ServerDataStore';
|
||||
import debounce from 'lodash/debounce';
|
||||
@@ -57,7 +58,11 @@ export async function startBackendExperimental(options: BackendServeOptions) {
|
||||
if (child && !child.killed && child.exitCode === null) {
|
||||
// We always wait for the existing process to exit, to make sure we don't get IPC conflicts
|
||||
shutdownPromise = new Promise(resolve => child!.once('exit', resolve));
|
||||
child.kill();
|
||||
if (process.platform === 'win32' && child.pid) {
|
||||
ctrlc(child.pid);
|
||||
} else {
|
||||
child.kill();
|
||||
}
|
||||
await shutdownPromise;
|
||||
shutdownPromise = undefined;
|
||||
}
|
||||
|
||||
@@ -3795,6 +3795,7 @@ __metadata:
|
||||
cross-fetch: ^3.1.5
|
||||
cross-spawn: ^7.0.3
|
||||
css-loader: ^6.5.1
|
||||
ctrlc-windows: ^2.1.0
|
||||
del: ^7.0.0
|
||||
diff: ^5.0.0
|
||||
esbuild: ^0.19.0
|
||||
@@ -23048,6 +23049,13 @@ __metadata:
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"ctrlc-windows@npm:^2.1.0":
|
||||
version: 2.1.0
|
||||
resolution: "ctrlc-windows@npm:2.1.0"
|
||||
checksum: 0f0582ba9516290d3e90ea7b91710f8b9b110e1ed29b7c84ebd44c16368b2553722b86a17226120ca3ea0ef679ac3596f48104cc113cfb7c3d07260f6c92e38b
|
||||
languageName: node
|
||||
linkType: hard
|
||||
|
||||
"d3-array@npm:2 - 3, d3-array@npm:2.10.0 - 3, d3-array@npm:^3.1.6":
|
||||
version: 3.2.3
|
||||
resolution: "d3-array@npm:3.2.3"
|
||||
|
||||
Reference in New Issue
Block a user