mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2025-06-17 14:28:13 +00:00
Sequential execution of stopping servers
This commit is contained in:
@ -9,23 +9,31 @@ function getServerArguments(server, overrides) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
async function stopAll() {
|
async function stopAll() {
|
||||||
Object.keys(runningServers).forEach(async (serverName) => {
|
for(var serverName in runningServers) {
|
||||||
await stop(serverName);
|
let result, error = await stop(serverName);
|
||||||
});
|
}
|
||||||
|
console.log(`Stopped all servers`);
|
||||||
}
|
}
|
||||||
|
|
||||||
async function stop(serverName) {
|
async function stop(serverName) {
|
||||||
const runningServer = runningServers[serverName];
|
const runningServer = runningServers[serverName];
|
||||||
const pid = runningServer.process.pid;
|
const pid = runningServer.process.pid;
|
||||||
console.log(`Stopping '${serverName}' with PID='${pid}'`);
|
console.log(`Stopping '${serverName}' with PID='${pid}'`);
|
||||||
|
|
||||||
|
const stopped = new Promise((resolve, reject) => {
|
||||||
kill(pid, (error) => {
|
kill(pid, (error) => {
|
||||||
if(error) {
|
if(error) {
|
||||||
console.error(`Error occured during stopping '${serverName}' with PID='${pid}'`);
|
console.error(`Error occured during stopping '${serverName}' with PID='${pid}'`);
|
||||||
|
reject(error);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
console.log(`Stopped '${serverName}' with PID='${pid}'`);
|
console.log(`Stopped '${serverName}' with PID='${pid}'`);
|
||||||
|
resolve(`Stopped '${serverName}' with PID='${pid}'`);
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
});
|
||||||
|
|
||||||
|
return stopped;
|
||||||
}
|
}
|
||||||
|
|
||||||
async function run(server, options) {
|
async function run(server, options) {
|
||||||
|
Reference in New Issue
Block a user