snapshot of https://github.com/RocketChat/Rocket.Chat.git (develop, 2026-09-16; blobs > 131072B omitted)
Some checks failed
Create issues from TODOs / todos (push) Failing after 3s
Close inactive issues / close-issues (push) Has been cancelled
Deploy GitHub Pages / deploy-preview (push) Has been cancelled
CI / ⚙️ Variables Setup (push) Has been cancelled
CI / ⚙️ Test Guard (push) Has been cancelled
CI / 🚀 Notify external services - draft (push) Has been cancelled
CI / 📦 Build Packages (push) Has been cancelled
CI / 📦 Meteor Build (coverage) (push) Has been cancelled
CI / 📦 Meteor Build (production) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [account-service presence-service omnichannel-transcript-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [authorization-service queue-worker-service ddp-streamer-service], fips) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Build Docker (amd64, [rocketchat], fips) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [account-service presence-service omnichannel-transcript-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [authorization-service queue-worker-service ddp-streamer-service], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], ${{ (github.event_name != 'release' && github.ref != 'refs/heads/develop') && 'coverage' || 'production' }}) (push) Has been cancelled
CI / 🚢 Build Docker (arm64, [rocketchat], coverage) (push) Has been cancelled
CI / 🚢 Publish Docker Images (ghcr.io) (push) Has been cancelled
CI / 📦 Track Image Sizes (push) Has been cancelled
CI / 🔎 Code Check - Action Lint (push) Has been cancelled
CI / 🔎 Code Check (push) Has been cancelled
CI / 🔨 Test Storybook (push) Has been cancelled
CI / 🔨 Test Unit (push) Has been cancelled
CI / 🔨 Test API (CE) (push) Has been cancelled
CI / 🔨 Test API Livechat (CE) (push) Has been cancelled
CI / 🔨 Test UI (CE) (push) Has been cancelled
CI / 🔨 Test API (EE) (push) Has been cancelled
CI / 🔨 Test API Livechat (EE) (push) Has been cancelled
CI / 🔨 Test API Apps (deno-runtime - EE) (push) Has been cancelled
CI / 🔨 Test UI (EE) (push) Has been cancelled
CI / 🔨 Test API (FIPS) (push) Has been cancelled
CI / 🔨 Test API Livechat (FIPS) (push) Has been cancelled
CI / 🔨 Test UI (FIPS) (push) Has been cancelled
CI / 🔨 Test Federation Matrix (push) Has been cancelled
CI / 📊 Report Coverage (push) Has been cancelled
CI / ✅ Tests Done (push) Has been cancelled
CI / 🚀 Publish build assets (push) Has been cancelled
CI / 🚀 Publish Docker Images (DockerHub) (push) Has been cancelled
CI / 🚀 Notify external services (push) Has been cancelled
CI / Update Version Durability (push) Has been cancelled
Release / Release (push) Has been cancelled
Auto-close duplicate issues / auto-close-duplicates (push) Failing after 1s
Code scanning - action / CodeQL-Build (push) Failing after 2s

This commit is contained in:
upstream-mirror
2026-09-16 01:21:02 +05:00
commit 30810eecd7
10161 changed files with 987110 additions and 0 deletions

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,30 @@
{
"name": "@rocket.chat/instance-status",
"version": "0.1.60",
"private": true,
"main": "./dist/index.js",
"typings": "./dist/index.d.ts",
"files": [
"/dist"
],
"scripts": {
"build": "rm -rf dist && tsc -p tsconfig.json",
"dev": "tsc --watch --preserveWatchOutput -p tsconfig.json",
"lint": "eslint .",
"lint:fix": "eslint --fix .",
"test": "echo \"Error: no test specified\" && exit 1"
},
"dependencies": {
"@rocket.chat/models": "workspace:^",
"@rocket.chat/tracing": "workspace:^"
},
"devDependencies": {
"@rocket.chat/tsconfig": "workspace:*",
"eslint": "~9.39.5",
"mongodb": "6.16.0",
"typescript": "~5.9.3"
},
"volta": {
"extends": "../../package.json"
}
}

View File

@@ -0,0 +1,111 @@
import { randomUUID } from 'node:crypto';
import type { IInstanceStatus } from '@rocket.chat/core-typings';
import { InstanceStatus as InstanceStatusModel } from '@rocket.chat/models';
export const defaultPingInterval = parseInt(String(process.env.MULTIPLE_INSTANCES_PING_INTERVAL)) || 10;
export const indexExpire = (parseInt(String(process.env.MULTIPLE_INSTANCES_EXPIRE)) || Math.ceil((defaultPingInterval * 3) / 60)) * 60;
const ID = randomUUID();
const id = (): IInstanceStatus['_id'] => ID;
const currentInstance = {
name: '',
extraInformation: {},
};
let pingInterval: NodeJS.Timeout | null;
function start() {
stop();
pingInterval = setInterval(async () => ping(), defaultPingInterval * 1000);
}
function stop() {
if (!pingInterval) {
return;
}
clearInterval(pingInterval);
pingInterval = null;
}
let createIndexes = async () => {
await InstanceStatusModel.col
.indexes()
.catch(() => [])
.then((result) =>
result.some((index) => {
if (index.key && index.key._updatedAt === 1) {
if (index.expireAfterSeconds !== indexExpire && index.name) {
void InstanceStatusModel.col.dropIndex(index.name);
return false;
}
return true;
}
return false;
}),
)
.then((created) => {
if (!created) {
void InstanceStatusModel.col.createIndex({ _updatedAt: 1 }, { expireAfterSeconds: indexExpire });
}
});
createIndexes = async () => {
// noop
};
};
async function registerInstance(name: string, extraInformation: Partial<IInstanceStatus['extraInformation']>): Promise<unknown> {
void createIndexes();
currentInstance.name = name;
currentInstance.extraInformation = extraInformation;
const result = await InstanceStatusModel.upsertInstance({
_id: id(),
pid: process.pid,
name,
extraInformation: extraInformation as IInstanceStatus['extraInformation'],
});
start();
process.on('exit', onExit);
return result;
}
async function unregisterInstance() {
try {
const result = await InstanceStatusModel.removeInstanceById(id());
stop();
process.removeListener('exit', onExit);
return result;
} catch (e) {
return e;
}
}
async function updateConnections(connections: number) {
await InstanceStatusModel.updateConnections(id(), connections);
}
async function ping() {
const result = await InstanceStatusModel.setDocumentHeartbeat(ID);
if (result.modifiedCount === 0) {
await registerInstance(currentInstance.name, currentInstance.extraInformation);
}
}
async function onExit() {
await unregisterInstance();
}
export const InstanceStatus = {
defaultPingInterval,
id,
indexExpire,
registerInstance,
updateConnections,
};

View File

@@ -0,0 +1,9 @@
{
"extends": "@rocket.chat/tsconfig/server.json",
"compilerOptions": {
"declaration": true,
"rootDir": "./src",
"outDir": "./dist"
},
"include": ["./src/**/*"]
}