mirror of
https://github.com/GNS3/gns3-web-ui.git
synced 2024-12-19 21:17:51 +00:00
Support of stderr CRITICAL issues forwarded to app
This commit is contained in:
parent
16185d2461
commit
cdadbd9140
@ -67,6 +67,19 @@ function notifyStatus(status) {
|
|||||||
ipcMain.emit('local-server-status-events', status);
|
ipcMain.emit('local-server-status-events', status);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
function filterOutput(line) {
|
||||||
|
const index = line.search('CRITICAL');
|
||||||
|
if(index > -1) {
|
||||||
|
return {
|
||||||
|
isCritical: true,
|
||||||
|
errorMessage: line.substr(index)
|
||||||
|
};
|
||||||
|
}
|
||||||
|
return {
|
||||||
|
isCritical: false
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
async function stopAll() {
|
async function stopAll() {
|
||||||
for(var serverName in runningServers) {
|
for(var serverName in runningServers) {
|
||||||
let result, error = await stop(serverName);
|
let result, error = await stop(serverName);
|
||||||
@ -137,6 +150,16 @@ async function run(server, options) {
|
|||||||
};
|
};
|
||||||
|
|
||||||
serverProcess.stdout.on('data', function(data) {
|
serverProcess.stdout.on('data', function(data) {
|
||||||
|
const line = data.toString();
|
||||||
|
const { isCritical, errorMessage } = filterOutput(line);
|
||||||
|
if(isCritical) {
|
||||||
|
notifyStatus({
|
||||||
|
serverName: server.name,
|
||||||
|
status: 'stderr',
|
||||||
|
message: `Server reported error: '${errorMessage}`
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
if(logStdout) {
|
if(logStdout) {
|
||||||
console.log(data.toString());
|
console.log(data.toString());
|
||||||
}
|
}
|
||||||
@ -149,17 +172,19 @@ async function run(server, options) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
serverProcess.on('exit', (code, signal) => {
|
serverProcess.on('exit', (code, signal) => {
|
||||||
if(code > 0) {
|
notifyStatus({
|
||||||
notifyStatus({
|
serverName: server.name,
|
||||||
serverName: server.name,
|
status: 'errored',
|
||||||
status: 'errored',
|
message: `Server '${server.name}' has exited with status='${code}'`
|
||||||
message: `Server '${server.name}' has exited with status='${code}'`
|
});
|
||||||
});
|
|
||||||
}
|
|
||||||
});
|
});
|
||||||
|
|
||||||
serverProcess.on('error', (err) => {
|
serverProcess.on('error', (err) => {
|
||||||
|
notifyStatus({
|
||||||
|
serverName: server.name,
|
||||||
|
status: 'errored',
|
||||||
|
message: `Server errored: '${errorMessage}`
|
||||||
|
});
|
||||||
});
|
});
|
||||||
|
|
||||||
}
|
}
|
||||||
@ -183,10 +208,6 @@ ipcMain.on('local-server-run', async function (event, server) {
|
|||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
ipcMain.on('before-quit', async function (event) {
|
|
||||||
console.log(event);
|
|
||||||
});
|
|
||||||
|
|
||||||
if (require.main === module) {
|
if (require.main === module) {
|
||||||
process.on('SIGINT', function() {
|
process.on('SIGINT', function() {
|
||||||
console.log("Caught interrupt signal");
|
console.log("Caught interrupt signal");
|
||||||
|
4
main.js
4
main.js
@ -63,7 +63,7 @@ function createWindow () {
|
|||||||
// Dereference the window object, usually you would store windows
|
// Dereference the window object, usually you would store windows
|
||||||
// in an array if your app supports multi windows, this is the time
|
// in an array if your app supports multi windows, this is the time
|
||||||
// when you should delete the corresponding element.
|
// when you should delete the corresponding element.
|
||||||
mainWindow = null
|
mainWindow = null;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
||||||
@ -94,7 +94,7 @@ app.on('activate', function () {
|
|||||||
// On OS X it's common to re-create a window in the app when the
|
// On OS X it's common to re-create a window in the app when the
|
||||||
// dock icon is clicked and there are no other windows open.
|
// dock icon is clicked and there are no other windows open.
|
||||||
if (mainWindow === null) {
|
if (mainWindow === null) {
|
||||||
createWindow()
|
createWindow();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
@ -32,6 +32,9 @@ export class DefaultLayoutComponent implements OnInit, OnDestroy {
|
|||||||
if(serverStatus.status === 'errored') {
|
if(serverStatus.status === 'errored') {
|
||||||
this.toasterService.error(serverStatus.message);
|
this.toasterService.error(serverStatus.message);
|
||||||
}
|
}
|
||||||
|
if(serverStatus.status === 'stderr') {
|
||||||
|
this.toasterService.error(serverStatus.message);
|
||||||
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
// stop servers only when in Electron
|
// stop servers only when in Electron
|
||||||
|
@ -5,7 +5,7 @@ import { Subject } from 'rxjs';
|
|||||||
|
|
||||||
export interface ServerStateEvent {
|
export interface ServerStateEvent {
|
||||||
serverName: string;
|
serverName: string;
|
||||||
status: "started" | "errored" | "stopped";
|
status: "started" | "errored" | "stopped" | "stderr";
|
||||||
message: string;
|
message: string;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user