|
|
@ -22,13 +22,13 @@ const electron = require('electron'), |
|
|
|
const fixPath = require('fix-path'); |
|
|
|
var ps = require('ps-node'), |
|
|
|
setconf = require('../private/setconf.js'), |
|
|
|
//coincli = require('../private/coincli.js'),
|
|
|
|
assetChainPorts = require('./ports.js'), |
|
|
|
shepherd = express.Router(), |
|
|
|
iguanaInstanceRegistry = {}, |
|
|
|
syncOnlyIguanaInstanceInfo = {}, |
|
|
|
syncOnlyInstanceInterval = -1, |
|
|
|
guiLog = {}; |
|
|
|
guiLog = {}, |
|
|
|
rpcConf = {}; |
|
|
|
|
|
|
|
// IGUANA FILES AND CONFIG SETTINGS
|
|
|
|
var iguanaConfsDirSrc = path.join(__dirname, '../assets/deps/confs'), |
|
|
@ -39,32 +39,32 @@ var iguanaConfsDirSrc = path.join(__dirname, '../assets/deps/confs'), |
|
|
|
if (os.platform() === 'darwin') { |
|
|
|
fixPath(); |
|
|
|
var iguanaBin = path.join(__dirname, '../assets/bin/osx/iguana'), |
|
|
|
iguanaDir = process.env.HOME + '/Library/Application Support/iguana', |
|
|
|
iguanaConfsDir = iguanaDir + '/confs', |
|
|
|
iguanaDir = `${process.env.HOME}/Library/Application Support/iguana`, |
|
|
|
iguanaConfsDir = `${iguanaDir}/confs`, |
|
|
|
komododBin = path.join(__dirname, '../assets/bin/osx/komodod'), |
|
|
|
komodocliBin = path.join(__dirname, '../assets/bin/osx/komodo-cli'), |
|
|
|
komodoDir = process.env.HOME + '/Library/Application Support/Komodo', |
|
|
|
komodoDir = `${process.env.HOME}/Library/Application Support/Komodo`, |
|
|
|
zcashdBin = '/Applications/ZCashSwingWalletUI.app/Contents/MacOS/zcashd', |
|
|
|
zcashcliBin = '/Applications/ZCashSwingWalletUI.app/Contents/MacOS/zcash-cli', |
|
|
|
zcashDir = process.env.HOME + '/Library/Application Support/Zcash'; |
|
|
|
zcashDir = `${process.env.HOME}/Library/Application Support/Zcash`; |
|
|
|
} |
|
|
|
|
|
|
|
if (os.platform() === 'linux') { |
|
|
|
var iguanaBin = path.join(__dirname, '../assets/bin/linux64/iguana'), |
|
|
|
iguanaDir = process.env.HOME + '/.iguana', |
|
|
|
iguanaConfsDir = iguanaDir + '/confs', |
|
|
|
iguanaDir = `${process.env.HOME}/.iguana`, |
|
|
|
iguanaConfsDir = `${iguanaDir}/confs`, |
|
|
|
iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/128x128.png'), |
|
|
|
komododBin = path.join(__dirname, '../assets/bin/linux64/komodod'), |
|
|
|
komodocliBin = path.join(__dirname, '../assets/bin/linux64/komodo-cli'), |
|
|
|
komodoDir = process.env.HOME + '/.komodo'; |
|
|
|
komodoDir = `${process.env.HOME}/.komodo`; |
|
|
|
} |
|
|
|
|
|
|
|
if (os.platform() === 'win32') { |
|
|
|
var iguanaBin = path.join(__dirname, '../assets/bin/win64/iguana.exe'); |
|
|
|
iguanaBin = path.normalize(iguanaBin); |
|
|
|
iguanaDir = process.env.APPDATA + '/iguana'; |
|
|
|
iguanaDir = `${process.env.APPDATA}/iguana`; |
|
|
|
iguanaDir = path.normalize(iguanaDir); |
|
|
|
iguanaConfsDir = process.env.APPDATA + '/iguana/confs'; |
|
|
|
iguanaConfsDir = `${process.env.APPDATA}/iguana/confs`; |
|
|
|
iguanaConfsDir = path.normalize(iguanaConfsDir); |
|
|
|
iguanaIcon = path.join(__dirname, '/assets/icons/agama_icons/agama_app_icon.ico'), |
|
|
|
iguanaConfsDirSrc = path.normalize(iguanaConfsDirSrc), |
|
|
@ -72,7 +72,7 @@ if (os.platform() === 'win32') { |
|
|
|
komododBin = path.normalize(komododBin), |
|
|
|
komodocliBin = path.join(__dirname, '../assets/bin/win64/komodo-cli.exe'), |
|
|
|
komodocliBin = path.normalize(komodocliBin), |
|
|
|
komodoDir = process.env.APPDATA + '/Komodo', |
|
|
|
komodoDir = `${process.env.APPDATA}/Komodo`, |
|
|
|
komodoDir = path.normalize(komodoDir); |
|
|
|
} |
|
|
|
|
|
|
@ -94,20 +94,24 @@ shepherd.appConfig = { |
|
|
|
"v2": true, |
|
|
|
"useBasiliskInstance": true, |
|
|
|
"debug": true, |
|
|
|
"cli": { |
|
|
|
"passthru": false, |
|
|
|
"default": false |
|
|
|
} |
|
|
|
}; |
|
|
|
|
|
|
|
shepherd.writeLog = function(data) { |
|
|
|
const logLocation = iguanaDir + '/shepherd'; |
|
|
|
const logLocation = `${iguanaDir}/shepherd`; |
|
|
|
const timeFormatted = new Date(Date.now()).toLocaleString('en-US', { hour12: false }); |
|
|
|
|
|
|
|
if (fs.existsSync(logLocation + '/agamalog.txt')) { |
|
|
|
fs.appendFile(logLocation + '/agamalog.txt', timeFormatted + ' ' + data + '\r\n', function (err) { |
|
|
|
if (fs.existsSync(`${logLocation}/agamalog.txt`)) { |
|
|
|
fs.appendFile(`${logLocation}/agamalog.txt`, `${timeFormatted} ${data}\r\n`, function (err) { |
|
|
|
if (err) { |
|
|
|
console.log('error writing log file'); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
fs.writeFile(logLocation + '/agamalog.txt', timeFormatted + ' ' + data + '\r\n', function (err) { |
|
|
|
fs.writeFile(`${logLocation}/agamalog.txt`, `${timeFormatted} ${data}\r\n`, function (err) { |
|
|
|
if (err) { |
|
|
|
console.log('error writing log file'); |
|
|
|
} |
|
|
@ -118,19 +122,21 @@ shepherd.writeLog = function(data) { |
|
|
|
shepherd.createIguanaDirs = function() { |
|
|
|
if (!fs.existsSync(iguanaDir)) { |
|
|
|
fs.mkdirSync(iguanaDir); |
|
|
|
|
|
|
|
if (fs.existsSync(iguanaDir)) { |
|
|
|
console.log('created iguana folder at ' + iguanaDir); |
|
|
|
shepherd.writeLog('created iguana folder at ' + iguanaDir); |
|
|
|
console.log(`created iguana folder at ${iguanaDir}`); |
|
|
|
shepherd.writeLog(`created iguana folder at ${iguanaDir}`); |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.log('iguana folder already exists'); |
|
|
|
} |
|
|
|
|
|
|
|
if (!fs.existsSync(iguanaDir + '/shepherd')) { |
|
|
|
fs.mkdirSync(iguanaDir + '/shepherd'); |
|
|
|
if (!fs.existsSync(`${iguanaDir}/shepherd`)) { |
|
|
|
fs.mkdirSync(`${iguanaDir}/shepherd`); |
|
|
|
|
|
|
|
if (fs.existsSync(iguanaDir)) { |
|
|
|
console.log('created shepherd folder at ' + iguanaDir + '/shepherd'); |
|
|
|
shepherd.writeLog('create shepherd folder at ' + iguanaDir + '/shepherd'); |
|
|
|
console.log(`created shepherd folder at ${iguanaDir}/shepherd`); |
|
|
|
shepherd.writeLog(`create shepherd folder at ${iguanaDir}/shepherd`); |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.log('shepherd folder already exists'); |
|
|
@ -138,8 +144,8 @@ shepherd.createIguanaDirs = function() { |
|
|
|
} |
|
|
|
|
|
|
|
shepherd.get('/coinslist', function(req, res, next) { |
|
|
|
if (fs.existsSync(iguanaDir + '/shepherd/coinslist.json')) { |
|
|
|
fs.readFile(iguanaDir + '/shepherd/coinslist.json', 'utf8', function (err, data) { |
|
|
|
if (fs.existsSync(`${iguanaDir}/shepherd/coinslist.json`)) { |
|
|
|
fs.readFile(`${iguanaDir}/shepherd/coinslist.json`, 'utf8', function (err, data) { |
|
|
|
if (err) { |
|
|
|
const errorObj = { |
|
|
|
'msg': 'error', |
|
|
@ -171,7 +177,7 @@ shepherd.get('/coinslist', function(req, res, next) { |
|
|
|
* params: payload |
|
|
|
*/ |
|
|
|
shepherd.post('/guilog', function(req, res, next) { |
|
|
|
const logLocation = iguanaDir + '/shepherd'; |
|
|
|
const logLocation = `${iguanaDir}/shepherd`; |
|
|
|
|
|
|
|
if (!guiLog[shepherd.appSessionHash]) { |
|
|
|
guiLog[shepherd.appSessionHash] = {}; |
|
|
@ -190,7 +196,7 @@ shepherd.post('/guilog', function(req, res, next) { |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
fs.writeFile(logLocation + '/agamalog.json', JSON.stringify(guiLog), function (err) { |
|
|
|
fs.writeFile(`${logLocation}/agamalog.json`, JSON.stringify(guiLog), function (err) { |
|
|
|
if (err) { |
|
|
|
shepherd.writeLog('error writing gui log file'); |
|
|
|
} |
|
|
@ -207,8 +213,8 @@ shepherd.post('/guilog', function(req, res, next) { |
|
|
|
shepherd.get('/getlog', function(req, res, next) { |
|
|
|
const logExt = req.query.type === 'txt' ? 'txt' : 'json'; |
|
|
|
|
|
|
|
if (fs.existsSync(iguanaDir + '/shepherd/agamalog.' + logExt)) { |
|
|
|
fs.readFile(iguanaDir + '/shepherd/agamalog.' + logExt, 'utf8', function (err, data) { |
|
|
|
if (fs.existsSync(`${iguanaDir}/shepherd/agamalog.${logExt}`)) { |
|
|
|
fs.readFile(`${iguanaDir}/shepherd/agamalog.${logExt}`, 'utf8', function (err, data) { |
|
|
|
if (err) { |
|
|
|
const errorObj = { |
|
|
|
'msg': 'error', |
|
|
@ -228,7 +234,7 @@ shepherd.get('/getlog', function(req, res, next) { |
|
|
|
} else { |
|
|
|
const errorObj = { |
|
|
|
'msg': 'error', |
|
|
|
'result': 'agama.' + logExt + ' doesn\'t exist' |
|
|
|
'result': `agama.${logExt} doesnt exist` |
|
|
|
}; |
|
|
|
|
|
|
|
res.end(JSON.stringify(errorObj)); |
|
|
@ -246,7 +252,7 @@ shepherd.post('/coinslist', function(req, res, next) { |
|
|
|
|
|
|
|
res.end(JSON.stringify(errorObj)); |
|
|
|
} else { |
|
|
|
fs.writeFile(cache.iguanaDir + '/shepherd/coinslist.json', JSON.stringify(_payload), function (err) { |
|
|
|
fs.writeFile(`${cache.iguanaDir}/shepherd/coinslist.json`, JSON.stringify(_payload), function (err) { |
|
|
|
if (err) { |
|
|
|
const errorObj = { |
|
|
|
'msg': 'error', |
|
|
@ -271,15 +277,48 @@ shepherd.quitKomodod = function(chain) { |
|
|
|
// exit komodod gracefully
|
|
|
|
console.log('exec ' + komodocliBin + (chain ? ' -ac_name=' + chain : '') + ' stop'); |
|
|
|
exec(komodocliBin + (chain ? ' -ac_name=' + chain : '') + ' stop', function(error, stdout, stderr) { |
|
|
|
console.log('stdout: ' + stdout) |
|
|
|
console.log('stderr: ' + stderr) |
|
|
|
console.log(`stdout: ${stdout}`); |
|
|
|
console.log(`stderr: ${stderr}`); |
|
|
|
|
|
|
|
if (error !== null) { |
|
|
|
console.log('exec error: ' + error) |
|
|
|
console.log(`exec error: ${error}`); |
|
|
|
} |
|
|
|
}); |
|
|
|
} |
|
|
|
|
|
|
|
shepherd.getConf = function(chain) { |
|
|
|
const _confLocation = chain === 'komodod' ? `${komodoDir}/komodo.conf` : `${komodoDir}/${chain}/${chain}.conf`; |
|
|
|
|
|
|
|
if (fs.existsSync(_confLocation)) { |
|
|
|
const _port = assetChainPorts[chain]; |
|
|
|
const _rpcConf = fs.readFileSync(_confLocation, 'utf8'); |
|
|
|
|
|
|
|
if (_rpcConf.length) { |
|
|
|
let _match; |
|
|
|
let parsedRpcConfig = { |
|
|
|
user: '', |
|
|
|
pass: '', |
|
|
|
port: _port |
|
|
|
}; |
|
|
|
|
|
|
|
if (_match = _rpcConf.match(/rpcuser=\s*(.*)/)) { |
|
|
|
parsedRpcConfig.user = _match[1]; |
|
|
|
} |
|
|
|
|
|
|
|
if ((_match = _rpcConf.match(/rpcpass=\s*(.*)/)) || |
|
|
|
(_match = _rpcConf.match(/rpcpassword=\s*(.*)/))) { |
|
|
|
parsedRpcConfig.pass = _match[1]; |
|
|
|
} |
|
|
|
|
|
|
|
rpcConf[chain === 'komodod' ? 'KMD' : chain] = parsedRpcConfig; |
|
|
|
} else { |
|
|
|
console.log(`${_confLocation} is empty`); |
|
|
|
} |
|
|
|
} else { |
|
|
|
console.log(`${_confLocation} doesnt exist`); |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
/* |
|
|
|
* type: POST |
|
|
|
* params: payload |
|
|
@ -292,7 +331,7 @@ shepherd.post('/cli', function(req, res, next) { |
|
|
|
}; |
|
|
|
|
|
|
|
res.end(JSON.stringify(errorObj)); |
|
|
|
} else if (!req.body.payload.cmd.match(/^[0-9a-zA-Z \[\]"'/\\]+$/g)) { |
|
|
|
} else if (!req.body.payload.cmd.match(/^[0-9a-zA-Z _\[\]"'/\\]+$/g)) { |
|
|
|
const errorObj = { |
|
|
|
'msg': 'error', |
|
|
|
'result': 'wrong cli string format' |
|
|
@ -301,34 +340,75 @@ shepherd.post('/cli', function(req, res, next) { |
|
|
|
res.end(JSON.stringify(errorObj)); |
|
|
|
} else { |
|
|
|
const _mode = req.body.payload.mode === 'passthru' ? 'passthru' : 'default'; |
|
|
|
const _chain = req.body.payload.chain ? req.body.payload.chain : ''; |
|
|
|
const _chain = req.body.payload.chain === 'KMD' ? null : req.body.payload.chain; |
|
|
|
const _cmd = req.body.payload.cmd; |
|
|
|
const _params = req.body.payload.params ? ' ' + req.body.payload.params : ''; |
|
|
|
|
|
|
|
exec(komodocliBin + (_chain ? ' -ac_name=' + _chain : '') + ' ' + _cmd + _params, function(error, stdout, stderr) { |
|
|
|
console.log('stdout: ' + stdout) |
|
|
|
console.log('stderr: ' + stderr) |
|
|
|
|
|
|
|
if (error !== null) { |
|
|
|
console.log('exec error: ' + error) |
|
|
|
} |
|
|
|
if (!rpcConf[_chain]) { |
|
|
|
shepherd.getConf(req.body.payload.chain === 'KMD' ? 'komodod' : req.body.payload.chain); |
|
|
|
} |
|
|
|
|
|
|
|
let responseObj; |
|
|
|
if (_mode === 'default') { |
|
|
|
let _body = { |
|
|
|
'agent': 'bitcoinrpc', |
|
|
|
'method': _cmd |
|
|
|
}; |
|
|
|
|
|
|
|
if (stderr) { |
|
|
|
responseObj = { |
|
|
|
'msg': 'error', |
|
|
|
'result': stderr |
|
|
|
}; |
|
|
|
} else { |
|
|
|
responseObj = { |
|
|
|
'msg': 'success', |
|
|
|
'result': stdout |
|
|
|
if (req.body.payload.params) { |
|
|
|
_body = { |
|
|
|
'agent': 'bitcoinrpc', |
|
|
|
'method': _cmd, |
|
|
|
'params': req.body.payload.params === ' ' ? [''] : req.body.payload.params |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
res.end(JSON.stringify(responseObj)); |
|
|
|
}); |
|
|
|
const options = { |
|
|
|
url: `http://localhost:${rpcConf[_chain].port}`, |
|
|
|
method: 'POST', |
|
|
|
auth: { |
|
|
|
'user': rpcConf[_chain].user, |
|
|
|
'pass': rpcConf[_chain].pass |
|
|
|
}, |
|
|
|
body: JSON.stringify(_body) |
|
|
|
}; |
|
|
|
|
|
|
|
// send back body on both success and error
|
|
|
|
// this bit replicates iguana core's behaviour
|
|
|
|
request(options, function (error, response, body) { |
|
|
|
if (response && |
|
|
|
response.statusCode && |
|
|
|
response.statusCode === 200) { |
|
|
|
res.end(body); |
|
|
|
} else { |
|
|
|
res.end(body); |
|
|
|
} |
|
|
|
}); |
|
|
|
} else { |
|
|
|
exec(komodocliBin + (_chain ? ' -ac_name=' + _chain : '') + ' ' + _cmd + _params, function(error, stdout, stderr) { |
|
|
|
console.log(`stdout: ${stdout}`); |
|
|
|
console.log(`stderr: ${stderr}`); |
|
|
|
|
|
|
|
if (error !== null) { |
|
|
|
console.log(`exec error: ${error}`); |
|
|
|
} |
|
|
|
|
|
|
|
let responseObj; |
|
|
|
|
|
|
|
if (stderr) { |
|
|
|
responseObj = { |
|
|
|
'msg': 'error', |
|
|
|
'result': stderr |
|
|
|
}; |
|
|
|
} else { |
|
|
|
responseObj = { |
|
|
|
'msg': 'success', |
|
|
|
'result': stdout |
|
|
|
}; |
|
|
|
} |
|
|
|
|
|
|
|
res.end(JSON.stringify(responseObj)); |
|
|
|
}); |
|
|
|
} |
|
|
|
} |
|
|
|
}); |
|
|
|
|
|
|
@ -357,14 +437,14 @@ shepherd.post('/appconf', function(req, res, next) { |
|
|
|
}); |
|
|
|
|
|
|
|
shepherd.saveLocalAppConf = function(appSettings) { |
|
|
|
var appConfFileName = iguanaDir + '/config.json'; |
|
|
|
let appConfFileName = `${iguanaDir}/config.json`; |
|
|
|
|
|
|
|
_fs.access(iguanaDir, fs.constants.R_OK, function(err) { |
|
|
|
if (!err) { |
|
|
|
|
|
|
|
var FixFilePermissions = function() { |
|
|
|
return new Promise(function(resolve, reject) { |
|
|
|
var result = 'config.json file permissions updated to Read/Write'; |
|
|
|
const result = 'config.json file permissions updated to Read/Write'; |
|
|
|
|
|
|
|
fsnode.chmodSync(appConfFileName, '0666'); |
|
|
|
|
|
|
@ -378,7 +458,7 @@ shepherd.saveLocalAppConf = function(appSettings) { |
|
|
|
|
|
|
|
var FsWrite = function() { |
|
|
|
return new Promise(function(resolve, reject) { |
|
|
|
var result = 'config.json write file is done' |
|
|
|
const result = 'config.json write file is done'; |
|
|
|
|
|
|
|
fs.writeFile(appConfFileName, |
|
|
|
JSON.stringify(appSettings) |
|
|
@ -393,8 +473,8 @@ shepherd.saveLocalAppConf = function(appSettings) { |
|
|
|
fsnode.chmodSync(appConfFileName, '0666'); |
|
|
|
setTimeout(function() { |
|
|
|
console.log(result); |
|
|
|
console.log('app conf.json file is created successfully at: ' + iguanaConfsDir); |
|
|
|
shepherd.writeLog('app conf.json file is created successfully at: ' + iguanaConfsDir); |
|
|
|
console.log(`app conf.json file is created successfully at: ${iguanaConfsDir}`); |
|
|
|
shepherd.writeLog(`app conf.json file is created successfully at: ${iguanaConfsDir}`); |
|
|
|
resolve(result); |
|
|
|
}, 2000); |
|
|
|
}); |
|
|
@ -407,15 +487,15 @@ shepherd.saveLocalAppConf = function(appSettings) { |
|
|
|
} |
|
|
|
|
|
|
|
shepherd.loadLocalConfig = function() { |
|
|
|
if (fs.existsSync(iguanaDir + '/config.json')) { |
|
|
|
var localAppConfig = fs.readFileSync(iguanaDir + '/config.json', 'utf8'); |
|
|
|
if (fs.existsSync(`${iguanaDir}/config.json`)) { |
|
|
|
let localAppConfig = fs.readFileSync(`${iguanaDir}/config.json`, 'utf8'); |
|
|
|
console.log('app config set from local file'); |
|
|
|
shepherd.writeLog('app config set from local file'); |
|
|
|
|
|
|
|
// find diff between local and hardcoded configs
|
|
|
|
// append diff to local config
|
|
|
|
var compareJSON = function(obj1, obj2) { |
|
|
|
var result = {}; |
|
|
|
let result = {}; |
|
|
|
|
|
|
|
for (var i in obj1) { |
|
|
|
if (!obj2.hasOwnProperty(i)) { |
|
|
@ -457,15 +537,15 @@ shepherd.loadLocalConfig = function() { |
|
|
|
|
|
|
|
shepherd.appConfig = shepherd.loadLocalConfig(); |
|
|
|
|
|
|
|
console.log('iguana dir: ' + iguanaDir); |
|
|
|
console.log('iguana bin: ' + iguanaBin); |
|
|
|
console.log(`iguana dir: ${iguanaDir}`); |
|
|
|
console.log(`iguana bin: ${iguanaBin}`); |
|
|
|
console.log('--------------------------') |
|
|
|
console.log('iguana dir: ' + komododBin); |
|
|
|
console.log('iguana bin: ' + komodoDir); |
|
|
|
shepherd.writeLog('iguana dir: ' + iguanaDir); |
|
|
|
shepherd.writeLog('iguana bin: ' + iguanaBin); |
|
|
|
shepherd.writeLog('iguana dir: ' + komododBin); |
|
|
|
shepherd.writeLog('iguana bin: ' + komodoDir); |
|
|
|
console.log(`iguana dir: ${komododBin}`); |
|
|
|
console.log(`iguana bin: ${komodoDir}`); |
|
|
|
shepherd.writeLog(`iguana dir: ${iguanaDir}`); |
|
|
|
shepherd.writeLog(`iguana bin: ${iguanaBin}`); |
|
|
|
shepherd.writeLog(`iguana dir: ${komododBin}`); |
|
|
|
shepherd.writeLog(`iguana bin: ${komodoDir}`); |
|
|
|
|
|
|
|
// END IGUANA FILES AND CONFIG SETTINGS
|
|
|
|
// default route
|
|
|
@ -526,7 +606,7 @@ shepherd.getSyncOnlyForksInfo = function() { |
|
|
|
if (iguanaInstanceRegistry[port].mode.indexOf('/sync') > -1) { |
|
|
|
syncOnlyIguanaInstanceInfo[port] = {}; |
|
|
|
request({ |
|
|
|
url: 'http://localhost:' + port + '/api/bitcoinrpc/getinfo?userpass=tmpIgRPCUser@' + shepherd.appSessionHash, |
|
|
|
url: `http://localhost:${port}/api/bitcoinrpc/getinfo?userpass=tmpIgRPCUser@${shepherd.appSessionHash}`, |
|
|
|
method: 'GET' |
|
|
|
}, function (error, response, body) { |
|
|
|
if (response && |
|
|
@ -541,7 +621,7 @@ shepherd.getSyncOnlyForksInfo = function() { |
|
|
|
} |
|
|
|
}); |
|
|
|
request({ |
|
|
|
url: 'http://localhost:' + port + '/api/SuperNET/activehandle?userpass=' + shepherd.appSessionHash, |
|
|
|
url: `http://localhost:${port}/api/SuperNET/activehandle?userpass=${shepherd.appSessionHash}`, |
|
|
|
method: 'GET' |
|
|
|
}, function (error, response, body) { |
|
|
|
if (response && |
|
|
@ -609,7 +689,7 @@ shepherd.get('/forks/restart', function(req, res, next) { |
|
|
|
'msg': 'success', |
|
|
|
'result': 'restarted' |
|
|
|
}; |
|
|
|
shepherd.writeLog('iguana fork pmid ' + _pmid + ' restarted'); |
|
|
|
shepherd.writeLog(`iguana fork pmid ${_pmid} restarted`); |
|
|
|
|
|
|
|
res.end(JSON.stringify(successObj)); |
|
|
|
}); |
|
|
@ -1219,10 +1299,24 @@ function herder(flock, data) { |
|
|
|
if (status === 'closed') { |
|
|
|
// start komodod via exec
|
|
|
|
if (data.ac_name === 'komodod') { |
|
|
|
console.log('exec' + komododBin + ' ' + data.ac_options.join(' ')); |
|
|
|
shepherd.writeLog('exec' + komododBin + ' ' + data.ac_options.join(' ')); |
|
|
|
const _customParamDict = { |
|
|
|
'silent': '&', |
|
|
|
'reindex': '-reindex', |
|
|
|
'change': '-pubkey=' |
|
|
|
}; |
|
|
|
let _customParam; |
|
|
|
|
|
|
|
if (data.ac_custom_param === 'silent' || |
|
|
|
data.ac_custom_param === 'reindex') { |
|
|
|
_customParam = ' ' + _customParamDict[data.ac_custom_param]; |
|
|
|
} else if (data.ac_custom_param === 'change' && data.ac_custom_param_value) { |
|
|
|
_customParam = ' ' + _customParamDict[data.ac_custom_param] + data.ac_custom_param_value; |
|
|
|
} |
|
|
|
|
|
|
|
console.log('exec' + komododBin + ' ' + data.ac_options.join(' ') + _customParam); |
|
|
|
shepherd.writeLog('exec' + komododBin + ' ' + data.ac_options.join(' ') + _customParam); |
|
|
|
|
|
|
|
exec(komododBin + ' ' + data.ac_options.join(' '), { |
|
|
|
exec(komododBin + ' ' + data.ac_options.join(' ') + _customParam, { |
|
|
|
maxBuffer: 1024 * 10000 // 10 mb
|
|
|
|
}, function(error, stdout, stderr) { |
|
|
|
// console.log('stdout: ' + stdout);
|
|
|
|