per process state in home server group

This commit is contained in:
Stephen Birarda 2015-12-21 12:59:44 -07:00
parent b70dde27df
commit 2b31332de0
4 changed files with 48 additions and 30 deletions

View file

@ -54,11 +54,11 @@
</div>
<div id="ds-status" class="process-status">
<div class="circle started"></div>
<div class="circle stopped"></div>
<span>Domain Server</span>
</div>
<div id="ac-status" class="process-status">
<div class="circle started"></div>
<div class="circle stopped"></div>
<span>Assignment Clients</span>
</div>
</div>

View file

@ -11,18 +11,27 @@ $(function() {
// $('#process-interface .power-on').prop('disabled', interfaceOn);
// $('#process-interface .power-off').prop('disabled', !interfaceOn);
var serverState = arg.home.state;
var serverCircles = $('#ds-status .circle, #ac-status .circle');
switch (serverState) {
var sendingProcess = arg;
var processState = sendingProcess.state;
var processCircle = null;
if (sendingProcess.name == "domain-server") {
processCircle = $('#ds-status .circle');
} else if (sendingProcess.name == "ac-monitor") {
processCircle = $('#ac-status .circle');
} else {
return;
}
switch (processState) {
case HFProcess.ProcessStates.STOPPED:
serverCircles.attr('class', 'circle stopped');
processCircle.attr('class', 'circle stopped');
break;
case HFProcess.ProcessStates.STOPPING:
serverCircles.attr('class', 'circle stopping');
processCircle.attr('class', 'circle stopping');
break;
case HFProcess.ProcessStates.STARTED:
serverCircles.attr('class', 'circle started');
processCircle.attr('class', 'circle started');
break;
}
}
@ -45,5 +54,5 @@ $(function() {
ipcRenderer.on('process-update', onProcessUpdate);
ipcRenderer.send('update');
ipcRenderer.send('update-all-processes');
});

View file

@ -114,10 +114,9 @@ app.on('ready', function() {
var pInterface = new Process('interface', interfacePath);
var homeServer = new ProcessGroup('home', [
new Process('domain_server', dsPath),
new Process('ac_monitor', acPath, ['-n6', '--log-directory', logPath])
new Process('domain-server', dsPath),
new Process('ac-monitor', acPath, ['-n6', '--log-directory', logPath])
]);
homeServer.start();
// make sure we stop child processes on app quit
app.on('quit', function(){
@ -130,37 +129,45 @@ app.on('ready', function() {
home: homeServer
};
function sendProcessUpdate() {
function sendProcessUpdate(process) {
if (mainWindow) {
console.log("Sending process update to web view");
mainWindow.webContents.send('process-update', processes);
console.log("Sending process update to web view for " + process.name);
mainWindow.webContents.send('process-update', process);
}
};
pInterface.on('state-update', sendProcessUpdate);
// handle process updates
// pInterface.on('state-update', sendProcessUpdate);
homeServer.on('state-update', sendProcessUpdate);
ipcMain.on('start-process', function(event, arg) {
pInterface.start();
sendProcessUpdate();
});
ipcMain.on('stop-process', function(event, arg) {
pInterface.stop();
sendProcessUpdate();
});
// start the home server
homeServer.start();
// ipcMain.on('start-process', function(event, arg) {
// pInterface.start();
// });
// ipcMain.on('stop-process', function(event, arg) {
// pInterface.stop();
// });
ipcMain.on('restart-server', function(event, arg) {
homeServer.restart();
sendProcessUpdate();
});
ipcMain.on('stop-server', function(event, arg) {
homeServer.stop();
sendProcessUpdate();
});
ipcMain.on('open-logs', function(event, arg) {
openFileBrowser(logPath);
});
ipcMain.on('update', sendProcessUpdate);
sendProcessUpdate();
ipcMain.on('update-all-processes', function(event, arg) {
// enumerate our processes and call sendProcessUpdate to update
// the window with their status
for (let process of homeServer.processes) {
sendProcessUpdate(process);
}
});
}
});

View file

@ -89,7 +89,7 @@ ProcessGroup.prototype = extend(ProcessGroup.prototype, {
this.restarting = false;
}
}
this.emit('state-update', this, process);
this.emit('state-update', process);
}
});
@ -196,6 +196,8 @@ Process.prototype = extend(Process.prototype, {
}
this.child.kill();
this.state = ProcessStates.STOPPING;
this.emit('state-update', this);
},
// Events