Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.
child_process.exec(sh1, function () {
child_process.exec(sh2, callback);
});
}
else {
var sh = 'kill -9 $(lsof -i:' + Evt.port + ' -t)';
child_process.exec(sh, callback);
}
}
// killPort(function (error, stdout, stderr) {
// if (error !== null) {
// console.log('kill port error: ' + error);
// }
server.listen(Evt.port);
console.log("Server runing at port: " + Evt.port + ".");
me.localUrl = Evt.localUrl;
me._started = true;
me.server = server;
// });
},
function killPort(callback) {
if (Common.isWin()) {
// & EXIT 表示只循环一次
// Leanote会有两个pid绑定端口, 另一个和electron相关, kill掉也会把自己kill掉
var sh1 = 'FOR /F "tokens=4 delims= " %P IN (\'netstat -a -n -o ^| findstr :' + Evt.port + '\') DO (TaskKill.exe /F /PID %P) & Exit';
var sh2 = 'FOR /F "tokens=5 delims= " %P IN (\'netstat -a -n -o ^| findstr :' + Evt.port + '\') DO (TaskKill.exe /F /PID %P) & Exit';
child_process.exec(sh1, function () {
child_process.exec(sh2, callback);
});
}
else {
var sh = 'kill -9 $(lsof -i:' + Evt.port + ' -t)';
child_process.exec(sh, callback);
}
}
// killPort(function (error, stdout, stderr) {
function killPort(callback) {
if (Common.isWin()) {
// & EXIT 表示只循环一次
// Leanote会有两个pid绑定端口, 另一个和electron相关, kill掉也会把自己kill掉
var sh1 = 'FOR /F "tokens=4 delims= " %P IN (\'netstat -a -n -o ^| findstr :' + Evt.port + '\') DO (TaskKill.exe /F /PID %P) & Exit';
var sh2 = 'FOR /F "tokens=5 delims= " %P IN (\'netstat -a -n -o ^| findstr :' + Evt.port + '\') DO (TaskKill.exe /F /PID %P) & Exit';
child_process.exec(sh1, function () {
child_process.exec(sh2, callback);
});
}
else {
var sh = 'kill -9 $(lsof -i:' + Evt.port + ' -t)';
child_process.exec(sh, callback);
}
}
killPort(function (error, stdout, stderr) {