Skip to content

Commit

Permalink
fix(local): only force kill on Windows
Browse files Browse the repository at this point in the history
closes TryGhost#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 TryGhost#366 as it actually didn't do
anything
  • Loading branch information
acburdine committed Jul 21, 2017
1 parent 991e7e9 commit be95343
Showing 1 changed file with 4 additions and 11 deletions.
15 changes: 4 additions & 11 deletions lib/utils/local-process.js
Original file line number Diff line number Diff line change
Expand Up @@ -29,14 +29,11 @@ class LocalProcess extends ProcessManager {
* @public
*/
start(cwd, environment) {
let isWindows = process.platorm === 'win32';

return new Promise((resolve, reject) => {
let cp = spawn('node', [process.argv[1] , 'run'], {
cwd: cwd,
detached: true,
// IPC doesn't work on windows, so we just use 'ignore'
stdio: isWindows ? 'ignore' : ['ignore', 'ignore', 'ignore', 'ipc'],
stdio: ['ignore', 'ignore', 'ignore', 'ipc'],
env: assign({}, process.env, {NODE_ENV: environment})
});

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

if (isWindows) {
cp.disconnect();
cp.unref();
return resolve();
}

// Wait until Ghost tells us that it's started correctly, then resolve
cp.on('message', (msg) => {
if (msg.error) {
Expand Down Expand Up @@ -96,7 +87,9 @@ class LocalProcess extends ProcessManager {
throw e;
}

return fkill(pid, {force: true}).catch((error) => {
let isWindows = process.platform === 'win32';

return fkill(pid, {force: isWindows}).catch((error) => {
// TODO: verify windows outputs same error message as mac/linux
if (!error.message.match(/No such process/)) {
throw error;
Expand Down

0 comments on commit be95343

Please sign in to comment.