+ safely close geth on Windows
This commit is contained in:
@@ -13,5 +13,4 @@
|
|||||||
<span class="cleanText">Clean blockchain data</span>
|
<span class="cleanText">Clean blockchain data</span>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
1
|
|
||||||
BIN
bin/StopGeth.dll
Normal file
BIN
bin/StopGeth.dll
Normal file
Binary file not shown.
BIN
bin/WrapGeth.exe
Normal file
BIN
bin/WrapGeth.exe
Normal file
Binary file not shown.
@@ -1,12 +1,18 @@
|
|||||||
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() {
|
||||||
// get the path of get and execute the child process
|
// get the path of get and execute the child process
|
||||||
try {
|
try {
|
||||||
@@ -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]);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user