Merge pull request #694 from jarrodldavis/fix/restart-server

Fix restarting server in dev
This commit is contained in:
Rich Harris
2019-05-20 22:23:29 -04:00
committed by GitHub

View File

@@ -267,14 +267,7 @@ class Watcher extends EventEmitter {
});
};
if (this.proc) {
this.proc.removeListener('exit', emitFatal);
this.proc.kill();
this.proc.on('exit', restart);
} else {
restart();
}
const start_server = () => {
// we need to give the child process its own DevTools port,
// otherwise Node will try to use the parent's (and fail)
const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/;
@@ -309,6 +302,19 @@ class Watcher extends EventEmitter {
});
this.proc.on('exit', emitFatal);
};
if (this.proc) {
this.proc.removeListener('exit', emitFatal);
this.proc.kill();
this.proc.on('exit', () => {
start_server();
restart();
});
} else {
start_server();
restart();
}
});
}
});