mirror of
https://github.com/kevin-DL/sapper.git
synced 2026-01-23 15:41:32 +00:00
Fix restarting server in dev
Wait for the server process to exit before starting a new one, so that the server debugger port is free when the new process begins.
This commit is contained in:
@@ -267,14 +267,7 @@ class Watcher extends EventEmitter {
|
|||||||
});
|
});
|
||||||
};
|
};
|
||||||
|
|
||||||
if (this.proc) {
|
const start_server = () => {
|
||||||
this.proc.removeListener('exit', emitFatal);
|
|
||||||
this.proc.kill();
|
|
||||||
this.proc.on('exit', restart);
|
|
||||||
} else {
|
|
||||||
restart();
|
|
||||||
}
|
|
||||||
|
|
||||||
// we need to give the child process its own DevTools port,
|
// we need to give the child process its own DevTools port,
|
||||||
// otherwise Node will try to use the parent's (and fail)
|
// otherwise Node will try to use the parent's (and fail)
|
||||||
const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/;
|
const debugArgRegex = /--inspect(?:-brk|-port)?|--debug-port/;
|
||||||
@@ -309,6 +302,19 @@ class Watcher extends EventEmitter {
|
|||||||
});
|
});
|
||||||
|
|
||||||
this.proc.on('exit', emitFatal);
|
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();
|
||||||
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|||||||
Reference in New Issue
Block a user