+ safely close geth on Windows

This commit is contained in:
Taegus
2018-12-22 10:19:48 +01:00
parent 62f8be866e
commit 0d98b8a03d
4 changed files with 11 additions and 5 deletions

View File

@@ -13,5 +13,4 @@
<span class="cleanText">Clean blockchain data</span>
</div>
</div>
</div>
1
</div>

BIN
bin/StopGeth.dll Normal file

Binary file not shown.

BIN
bin/WrapGeth.exe Normal file

Binary file not shown.

View File

@@ -1,12 +1,18 @@
const child_process = require('child_process');
const {app, dialog} = require('electron');
const path = require('path');
const fs = require('fs');
class Geth {
constructor() {
this.gethProcess = null;
this.logStream = fs.createWriteStream(path.join(app.getPath('userData'), 'gethlog.txt'));
}
_writeLog(text) {
this.logStream.write(text);
}
startGeth() {
// get the path of get and execute the child process
try {
@@ -17,10 +23,10 @@ class Geth {
app.quit();
});
this.gethProcess.stderr.on('data', function(data) {
console.log(data.toString());
EthoGeth._writeLog(data.toString() + '\n');
});
this.gethProcess.stdout.on('data', function(data) {
console.log(data.toString());
EthoGeth._writeLog(data.toString() + '\n');
});
} catch (e) {
dialog.showErrorBox("Error starting application", e);
@@ -29,7 +35,8 @@ class Geth {
}
stopGeth() {
this.gethProcess.kill('SIGINT');
const gethWrapePath = path.join(app.getPath('userData'), 'WrapGeth.exe');
child_process.spawnSync(gethWrapePath, [this.gethProcess.pid]);
}
}