Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Terminate webpack dev server process only on connection error #6520

Merged
merged 1 commit into from
Sep 23, 2019
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
22 changes: 6 additions & 16 deletions flow-server/src/main/resources/webpack.generated.js
Original file line number Diff line number Diff line change
Expand Up @@ -43,37 +43,27 @@ if (watchDogPort){

const net = require('net');

function setupWatchDog(firstRun){
function setupWatchDog(){
var client = new net.Socket();
client.connect(watchDogPort, 'localhost', function() {
if (firstRun){
console.debug('Watchdog connected.');
} else {
console.log('Watchdog connected.');
}
console.debug('Watchdog connected.');
});

client.on('error', function(){
console.error("Watchdog connection error. Terminating webpack process...");
console.log("Watchdog connection error. Terminating webpack process...");
client.destroy();
process.exit(0);
});

client.on('close', function() {
client.destroy();
if (firstRun){
console.debug('Watchdog connection closed. Trying to re-run watchdog.');
setupWatchDog(false);
}
else {
console.log('Watchdog connection closed. Terminating webpack process...');
process.exit(0);
}
console.debug('Watchdog connection closed. Trying to re-run watchdog.');
setupWatchDog();
});
}

if (watchDogPort){
setupWatchDog(true);
setupWatchDog();
}


Expand Down