Merge branch 'main' into beta1

This commit is contained in:
chalith
2022-07-08 16:57:48 +05:30
2 changed files with 13 additions and 5 deletions

View File

@@ -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:?}"

View File

@@ -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.