Skip to content
Merged
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
5 changes: 5 additions & 0 deletions .changeset/tall-timers-swim.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
---
'@rocket.chat/meteor': patch
---

Fixes deployment data from statistics not being updated between deployments
50 changes: 50 additions & 0 deletions apps/meteor/app/statistics/server/lib/statistics.ts
Original file line number Diff line number Diff line change
Expand Up @@ -599,4 +599,54 @@ export const statistics = {

return rcStatistics;
},
async updateDeploymentInfo(): Promise<void> {
const lastStatistics = await Statistics.findLast();

if (!lastStatistics) {
return;
}

const { mongoVersion, mongoStorageEngine } = await getMongoInfo();

const deploymentInfo: Partial<IStats> = {
os: {
type: os.type(),
platform: os.platform(),
arch: os.arch(),
release: os.release(),
uptime: os.uptime(),
loadavg: os.loadavg(),
totalmem: os.totalmem(),
freemem: os.freemem(),
cpus: os.cpus(),
},
process: {
nodeVersion: process.version,
pid: process.pid,
uptime: process.uptime(),
},
deploy: {
method: process.env.DEPLOY_METHOD || 'tar',
platform: process.env.DEPLOY_PLATFORM || 'selfinstall',
},
msEnabled: isRunningMs(),
mongoVersion,
mongoStorageEngine: mongoStorageEngine || '',
migration: await getControl(),
};

if (Info) {
deploymentInfo.version = Info.version;
}
Comment thread
coderabbitai[bot] marked this conversation as resolved.

const { _id, ...baseStatistics } = lastStatistics;

const newStatistics: Omit<IStats, '_id'> = {
...baseStatistics,
...deploymentInfo,
createdAt: new Date(),
};

await Statistics.insertOne(newStatistics);
},
Comment thread
coderabbitai[bot] marked this conversation as resolved.
Outdated
};
3 changes: 3 additions & 0 deletions apps/meteor/server/startup/serverRunning.ts
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@ import { Meteor } from 'meteor/meteor';
import semver from 'semver';

import { settings } from '../../app/settings/server';
import { statistics } from '../../app/statistics/server/lib/statistics';
import { Info } from '../../app/utils/rocketchat.info';
import { getMongoInfo } from '../../app/utils/server/functions/getMongoInfo';
// import { i18n } from '../lib/i18n';
Expand Down Expand Up @@ -78,6 +79,8 @@ Meteor.startup(async () => {
exitIfNotBypassed(process.env.BYPASS_MONGO_VALIDATION);
}

await statistics.updateDeploymentInfo();
Comment thread
cubic-dev-ai[bot] marked this conversation as resolved.
Outdated
Comment thread
nazabucciarelli marked this conversation as resolved.
Outdated

showSuccessBox('SERVER RUNNING', msg);

// Deprecation
Expand Down
Loading