Skip to content

Commit 1655806

Browse files
committed
fix(windows): fix local process manager on windows
closes #228
1 parent e8d4f31 commit 1655806

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

lib/utils/local-process.js

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

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

53+
if (isWindows) {
54+
cp.disconnect();
55+
cp.unref();
56+
return resolve();
57+
}
58+
5059
// Wait until Ghost tells us that it's started correctly, then resolve
5160
cp.on('message', (msg) => {
5261
if (msg.error) {
@@ -87,7 +96,7 @@ class LocalProcess extends ProcessManager {
8796
throw e;
8897
}
8998

90-
return fkill(pid).catch((error) => {
99+
return fkill(pid, {force: true}).catch((error) => {
91100
// TODO: verify windows outputs same error message as mac/linux
92101
if (!error.message.match(/No such process/)) {
93102
throw error;

0 commit comments

Comments
 (0)