+ 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

@@ -14,4 +14,3 @@
</div> </div>
</div> </div>
</div> </div>
1

BIN
bin/StopGeth.dll Normal file

Binary file not shown.

BIN
bin/WrapGeth.exe Normal file

Binary file not shown.

View File

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