Merge pull request #1109 from josepfo/fix/trying-to-update-not-installed-nodes

fix: skip not installed nodes
This commit is contained in:
Rafael Taranto 2022-02-14 23:50:48 +00:00 committed by GitHub
commit a7ee694169
2 changed files with 17 additions and 1 deletions

View file

@ -22,6 +22,18 @@ function plugin (crypto) {
return plugin return plugin
} }
function isWalletNodeInstalled (status) {
// From http://supervisord.org/subprocess.html#process-states
switch (status) {
case 'STARTING' || 'RUNNING' || 'STOPPED' || 'BACKOFF' || 'STOPPING' || 'EXITED' || 'FATAL':
return true
case 'UNKNOWN':
return false
default:
return false
}
}
function run () { function run () {
_.forEach((crypto) => { _.forEach((crypto) => {
if (!_.includes(crypto.cryptoCode, _.keys(PLUGINS))) return if (!_.includes(crypto.cryptoCode, _.keys(PLUGINS))) return
@ -29,6 +41,7 @@ function run () {
const cryptoPlugin = plugin(crypto) const cryptoPlugin = plugin(crypto)
const status = common.es(`sudo supervisorctl status ${crypto.code} | awk '{ print $2 }'`).trim() const status = common.es(`sudo supervisorctl status ${crypto.code} | awk '{ print $2 }'`).trim()
if (!isWalletNodeInstalled(status)) return
cryptoPlugin.updateCore(common.getBinaries(crypto.cryptoCode), _.includes(status, ['RUNNING', 'STARTING'])) cryptoPlugin.updateCore(common.getBinaries(crypto.cryptoCode), _.includes(status, ['RUNNING', 'STARTING']))
}, cryptos) }, cryptos)
} }

View file

@ -103,8 +103,11 @@ function setupCrypto (crypto) {
function updateCrypto (crypto) { function updateCrypto (crypto) {
if (!common.isUpdateDependent(crypto.cryptoCode)) return if (!common.isUpdateDependent(crypto.cryptoCode)) return
const cryptoPlugin = plugin(crypto) const cryptoPlugin = plugin(crypto)
// TODO: we need to refactor the way we retrieve this status, p.e Monero uses two
// services with specific names, so each coin should have its implementation.
// Currently, it's not a breaking change because only BTC is update dependent
const status = common.es(`sudo supervisorctl status ${crypto.code} | awk '{ print $2 }'`).trim() const status = common.es(`sudo supervisorctl status ${crypto.code} | awk '{ print $2 }'`).trim()
const isCurrentlyRunning = status === 'RUNNING' const isCurrentlyRunning = _.includes(status, ['RUNNING', 'STARTING'])
cryptoPlugin.updateCore(common.getBinaries(crypto.cryptoCode), isCurrentlyRunning) cryptoPlugin.updateCore(common.getBinaries(crypto.cryptoCode), isCurrentlyRunning)
} }