diff --git a/installer/sashimono-uninstall.sh b/installer/sashimono-uninstall.sh index 3606fcb..69d8c94 100755 --- a/installer/sashimono-uninstall.sh +++ b/installer/sashimono-uninstall.sh @@ -155,7 +155,10 @@ if grep -q "^$MB_XRPL_USER:" /etc/passwd; then fi echo "Deleting message board user..." - killall -u $MB_XRPL_USER # Kill any running processes. + # Killall command is not found in every linux systems, therefore pkill command is used. + # A small timeout(0.1 second) is applied before deleting the user because it takes some time to kill all the processes + pkill -u $MB_XRPL_USER # Kill any running processes. + sleep 0.1 userdel -f "$MB_XRPL_USER" rm -r /home/"${MB_XRPL_USER:?}" diff --git a/mb-xrpl/lib/message-board.js b/mb-xrpl/lib/message-board.js index 13e11a5..17530c9 100644 --- a/mb-xrpl/lib/message-board.js +++ b/mb-xrpl/lib/message-board.js @@ -73,6 +73,7 @@ class MessageBoard { await this.hostClient.updateRegInfo(this.activeInstanceCount, this.cfg.version); this.db.close(); + let ongoingHeartbeat = false; // Check for instance expiry. this.xrplApi.on(evernode.XrplApiEvents.LEDGER, async (e) => { this.lastValidatedLedgerIndex = e.ledger_index; @@ -80,13 +81,14 @@ class MessageBoard { const currentMoment = await this.hostClient.getMoment(e.ledger_index); // Sending heartbeat every CONF_HOST_HEARTBEAT_FREQ moments. - if (this.lastHeartbeatMoment === 0 || (currentMoment % this.hostClient.config.hostHeartbeatFreq === 0 && currentMoment !== this.lastHeartbeatMoment)) { - this.lastHeartbeatMoment = currentMoment; - - console.log(`Reporting heartbeat at Moment ${this.lastHeartbeatMoment}...`) + if ( ! ongoingHeartbeat && + (this.lastHeartbeatMoment === 0 || (currentMoment % this.hostClient.config.hostHeartbeatFreq === 0 && currentMoment !== this.lastHeartbeatMoment))) { + ongoingHeartbeat = true; + console.log(`Reporting heartbeat at Moment ${this.lastHeartbeatMoment}...`); try { await this.hostClient.heartbeat(); + this.lastHeartbeatMoment = currentMoment; } catch (err) { if (err.code === 'tecHOOK_REJECTED') @@ -94,6 +96,9 @@ class MessageBoard { else console.log("Heartbeat tx error", err); } + finally { + ongoingHeartbeat = false; + } } // Filter out instances which needed to be expired and destroy them.