Browse Source

AGP-230, faster kmd main conf creation

v0.25
pbca26 7 years ago
parent
commit
8b5c7f4dbe
  1. 2
      main.js
  2. 3
      package.json
  3. 61
      routes/shepherd.js

2
main.js

@ -107,7 +107,7 @@ process.once('loaded', () => {
process.setFdLimit(appConfig.maxDescriptors.darwin); process.setFdLimit(appConfig.maxDescriptors.darwin);
app.setAboutPanelOptions({ app.setAboutPanelOptions({
applicationName: app.getName(), applicationName: app.getName(),
applicationVersion: app.getVersion(), applicationVersion: `app.getVersion().replace('version=', '')}-beta`,
copyright: 'Released under the MIT license', copyright: 'Released under the MIT license',
credits: 'SuperNET Team' credits: 'SuperNET Team'
}) })

3
package.json

@ -33,6 +33,7 @@
"portscanner": "^2.1.1", "portscanner": "^2.1.1",
"ps-node": "^0.1.5", "ps-node": "^0.1.5",
"remote-file-size": "^3.0.3", "remote-file-size": "^3.0.3",
"request": "^2.80.0" "request": "^2.80.0",
"socket.io": "^1.7.3"
} }
} }

61
routes/shepherd.js

@ -2496,16 +2496,16 @@ function setConf(flock) {
return new Promise(function(resolve, reject) { return new Promise(function(resolve, reject) {
const result = 'Check Conf file exists is done' const result = 'Check Conf file exists is done'
fs.ensureFile(DaemonConfPath, function(err) { const confFileExist = fs.ensureFileSync(DaemonConfPath);
shepherd.log(err); // => null if (confFileExist) {
});
setTimeout(function() {
shepherd.log(result); shepherd.log(result);
shepherd.writeLog(`setconf ${result}`); shepherd.writeLog(`setconf ${result}`);
resolve(result); resolve(result);
}, 2000); } else {
shepherd.log('conf file doesnt exist');
resolve('conf file doesnt exist');
}
}); });
} }
@ -2514,13 +2514,10 @@ function setConf(flock) {
const result = 'Conf file permissions updated to Read/Write'; const result = 'Conf file permissions updated to Read/Write';
fsnode.chmodSync(DaemonConfPath, '0666'); fsnode.chmodSync(DaemonConfPath, '0666');
shepherd.log(result);
shepherd.writeLog(`setconf ${result}`);
setTimeout(function() { resolve(result);
shepherd.log(result);
shepherd.writeLog(`setconf ${result}`);
resolve(result);
}, 1000);
}); });
} }
@ -2539,16 +2536,13 @@ function setConf(flock) {
fs.writeFile(DaemonConfPath, rmlines, 'utf8', function(err) { fs.writeFile(DaemonConfPath, rmlines, 'utf8', function(err) {
if (err) if (err)
return shepherd.log(err); return shepherd.log(err);
fsnode.chmodSync(DaemonConfPath, '0666');
shepherd.writeLog(`setconf ${result}`);
shepherd.log(result);
resolve(result);
}); });
}); });
fsnode.chmodSync(DaemonConfPath, '0666');
setTimeout(function() {
shepherd.writeLog(`setconf ${result}`);
shepherd.log(result);
resolve(result);
}, 2000);
}); });
} }
@ -2565,7 +2559,7 @@ function setConf(flock) {
shepherd.log('rpcuser: OK'); shepherd.log('rpcuser: OK');
shepherd.writeLog('rpcuser: OK'); shepherd.writeLog('rpcuser: OK');
} else { } else {
const randomstring = md5(Math.random() * Math.random() * 999); const randomstring = md5((Math.random() * Math.random() * 999).toString());
shepherd.log('rpcuser: NOT FOUND'); shepherd.log('rpcuser: NOT FOUND');
shepherd.writeLog('rpcuser: NOT FOUND'); shepherd.writeLog('rpcuser: NOT FOUND');
@ -2593,7 +2587,7 @@ function setConf(flock) {
shepherd.log('rpcpassword: OK'); shepherd.log('rpcpassword: OK');
shepherd.writeLog('rpcpassword: OK'); shepherd.writeLog('rpcpassword: OK');
} else { } else {
var randomstring = md5(Math.random() * Math.random() * 999); var randomstring = md5((Math.random() * Math.random() * 999).toString());
shepherd.log('rpcpassword: NOT FOUND'); shepherd.log('rpcpassword: NOT FOUND');
shepherd.writeLog('rpcpassword: NOT FOUND'); shepherd.writeLog('rpcpassword: NOT FOUND');
@ -2705,27 +2699,10 @@ function setConf(flock) {
.then(addnode); .then(addnode);
}); });
setTimeout(function() { shepherd.log(result);
shepherd.log(result); shepherd.writeLog(`checkconf addnode ${result}`);
shepherd.writeLog(`checkconf addnode ${result}`);
resolve(result);
}, 2000);
});
}
const MakeConfReadOnly = function() { resolve(result);
return new Promise(function(resolve, reject) {
const result = 'Conf file permissions updated to Read Only';
fsnode.chmodSync(DaemonConfPath, '0400');
setTimeout(function() {
shepherd.log(result);
shepherd.writeLog(`MakeConfReadOnly ${result}`);
resolve(result);
}, 1000);
}); });
} }

Loading…
Cancel
Save