Skip to content
This repository has been archived by the owner on Feb 26, 2021. It is now read-only.

fix wrong cpu usage #175

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
23 changes: 17 additions & 6 deletions app/js/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -1137,7 +1137,7 @@ var App = (function(App, undefined) {

App.relaunchApplication = function(didFinalize) {
console.log("App.relaunchApplication: " + didFinalize);
// For light wallet, we want to make sure that everything is cleaned properly before restarting..
// For light wallet, we want to make sure that everything is cleaned properly before restarting..
if (global.lightWallet && App.windowIsReady && !didFinalize) {
console.log("Sending stopCcurl message to renderer");
win.webContents.send("stopCcurl", {"relaunch": true});
Expand Down Expand Up @@ -1389,10 +1389,23 @@ var App = (function(App, undefined) {
}

App.stopTrackingCPU = function() {
if (cpuTrackInterval) {
clearInterval(cpuTrackInterval);
if (!cpuTrackInterval) {
App.updateStatusBar({"cpu": ""});
return
}

clearInterval(cpuTrackInterval);

var pid;
if (settings.lightWallet == 1) {
pid = rendererPid;
} else if (server && server.pid) {
pid = server.pid;
}

if (pid) {
pusage.unmonitor(pid);
}
App.updateStatusBar({"cpu": ""});
}

App.trackCPU = function() {
Expand All @@ -1412,8 +1425,6 @@ var App = (function(App, undefined) {
App.updateStatusBar({"cpu": Math.round(stat.cpu).toFixed(2)});
}
});

pusage.unmonitor(pid);
} else {
console.log("Track CPU: No server PID");
if (cpuTrackInterval) {
Expand Down