make shards ping their own text listener channels

This commit is contained in:
HF 2024-02-05 11:49:47 +01:00
parent d9f54486f1
commit 9474688e8a
2 changed files with 7 additions and 1 deletions

View File

@ -33,7 +33,6 @@ const Help = () => {
const mouseSymbol = <kbd><GiMouse /></kbd>;
const touchSymbol = <kbd><MdTouchApp /></kbd>;
const bindShift = <kbd> {c('keybinds').t`Shift`}</kbd>;
const bindC = <kbd>{c('keybinds').t`C`}</kbd>;
const starhouseLink = <a href="https://twitter.com/starhousedev">starhouse </a>;
const vinikLink = <a href="https://twitter.com/Vinikdev">Vinikdev</a>;

View File

@ -176,6 +176,11 @@ class MessageBroker extends SocketEvents {
*/
async onShardListenMessage(message) {
try {
if (message === 'ping') {
const channel = `${LISTEN_PREFIX}:${this.thisShard}`;
this.pings[channel] = Date.now();
return;
}
const comma = message.indexOf(',');
const key = message.slice(0, comma);
console.log(`CLUSTER shard listener got ${key}`);
@ -443,6 +448,8 @@ class MessageBroker extends SocketEvents {
}
// send keep alive to others
this.publisher.publish(BROADCAST_CHAN, this.thisShard);
// ping to own text listener channel
this.publisher.publish(`${LISTEN_PREFIX}:${this.thisShard}`, 'ping');
// clean up dead shard requests
threshold -= 30000;
this.csReq = this.csReq.filter((r) => r.ts > threshold);