Skip to content

Commit be95343

Browse files
committed
fix(local): only force kill on Windows
closes #368 - force killing on mac/linux doesn't allow the child process (ghost run) to kill the ghost server process, resulting in a orphan process that the user has to kill manually - on windows force: true works because fkill kills the process tree, which includes the ghost server - remove windows-specific code from #366 as it actually didn't do anything
1 parent 991e7e9 commit be95343

File tree

1 file changed

+4
-11
lines changed

1 file changed

+4
-11
lines changed

lib/utils/local-process.js

+4-11
Original file line numberDiff line numberDiff line change
@@ -29,14 +29,11 @@ class LocalProcess extends ProcessManager {
2929
* @public
3030
*/
3131
start(cwd, environment) {
32-
let isWindows = process.platorm === 'win32';
33-
3432
return new Promise((resolve, reject) => {
3533
let cp = spawn('node', [process.argv[1] , 'run'], {
3634
cwd: cwd,
3735
detached: true,
38-
// IPC doesn't work on windows, so we just use 'ignore'
39-
stdio: isWindows ? 'ignore' : ['ignore', 'ignore', 'ignore', 'ipc'],
36+
stdio: ['ignore', 'ignore', 'ignore', 'ipc'],
4037
env: assign({}, process.env, {NODE_ENV: environment})
4138
});
4239

@@ -50,12 +47,6 @@ class LocalProcess extends ProcessManager {
5047
reject(new errors.GhostError(`Ghost process exited with code: ${code}`));
5148
});
5249

53-
if (isWindows) {
54-
cp.disconnect();
55-
cp.unref();
56-
return resolve();
57-
}
58-
5950
// Wait until Ghost tells us that it's started correctly, then resolve
6051
cp.on('message', (msg) => {
6152
if (msg.error) {
@@ -96,7 +87,9 @@ class LocalProcess extends ProcessManager {
9687
throw e;
9788
}
9889

99-
return fkill(pid, {force: true}).catch((error) => {
90+
let isWindows = process.platform === 'win32';
91+
92+
return fkill(pid, {force: isWindows}).catch((error) => {
10093
// TODO: verify windows outputs same error message as mac/linux
10194
if (!error.message.match(/No such process/)) {
10295
throw error;

0 commit comments

Comments
 (0)