@matterbridge/core 3.9.3 → 3.9.4-dev-20260706-08fe8ef

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -56,10 +56,10 @@ export function getPlatformMatterbridge() {
56
56
  matterbridgePluginDirectory: path.join(HOMEDIR, 'Matterbridge'),
57
57
  matterbridgeCertDirectory: path.join(HOMEDIR, '.mattercert'),
58
58
  globalModulesDirectory: path.join(HOMEDIR, 'node_modules'),
59
- matterbridgeVersion: '3.9.3',
60
- matterbridgeLatestVersion: '3.9.3',
61
- matterbridgeDevVersion: '3.9.3',
62
- frontendVersion: '3.9.3',
59
+ matterbridgeVersion: '3.9.4',
60
+ matterbridgeLatestVersion: '3.9.4',
61
+ matterbridgeDevVersion: '3.9.4',
62
+ frontendVersion: '3.9.4',
63
63
  bridgeMode: '',
64
64
  restartMode: '',
65
65
  virtualMode: 'mounted_switch',
@@ -109,7 +109,7 @@ export async function createMatterbridgeEnvironment() {
109
109
  matterbridge = await Matterbridge.loadInstance(false);
110
110
  expect(matterbridge).toBeDefined();
111
111
  expect(matterbridge).toBeInstanceOf(Matterbridge);
112
- matterbridge.matterbridgeVersion = '3.9.3';
112
+ matterbridge.matterbridgeVersion = '3.9.4';
113
113
  matterbridge.bridgeMode = 'bridge';
114
114
  matterbridge.rootDirectory = path.join(HOMEDIR);
115
115
  matterbridge.homeDirectory = path.join(HOMEDIR);
@@ -71,6 +71,11 @@ export declare class Matterbridge extends EventEmitter<MatterbridgeEvents> {
71
71
  private readonly failCountLimit;
72
72
  hasCleanupStarted: boolean;
73
73
  private initialized;
74
+ private readonly isShutdownCommand;
75
+ private startupAt;
76
+ private shutdownAt;
77
+ private runningTimes;
78
+ private runningDays;
74
79
  private startMatterInterval;
75
80
  private readonly startMatterIntervalMs;
76
81
  private checkUpdateInterval;
@@ -104,6 +104,11 @@ export class Matterbridge extends EventEmitter {
104
104
  failCountLimit = 300;
105
105
  hasCleanupStarted = false;
106
106
  initialized = false;
107
+ isShutdownCommand = hasAnyParameter('list', 'logstorage', 'loginterfaces', 'systemcheck', 'add', 'remove', 'enable', 'disable', 'reset', 'factoryreset');
108
+ startupAt = 0;
109
+ shutdownAt = 0;
110
+ runningTimes = 0;
111
+ runningDays = 0;
107
112
  startMatterInterval;
108
113
  startMatterIntervalMs = 1000;
109
114
  checkUpdateInterval;
@@ -454,6 +459,19 @@ export class Matterbridge extends EventEmitter {
454
459
  if (!this.nodeStorage || !this.nodeContext) {
455
460
  throw new Error('Fatal error creating node storage manager and context for matterbridge');
456
461
  }
462
+ if (!this.isShutdownCommand) {
463
+ const lastStartupAt = await this.nodeContext.get('lastStartupAt', 0);
464
+ const lastShutdownAt = await this.nodeContext.get('lastShutdownAt', 0);
465
+ if (lastStartupAt && lastShutdownAt && lastShutdownAt < lastStartupAt) {
466
+ this.log.warn(`Matterbridge was not shut down properly. Last started at ${CYAN}${new Date(lastStartupAt).toLocaleString()}${db}, last shut down at ${CYAN}${new Date(lastShutdownAt).toLocaleString()}${db}`);
467
+ }
468
+ this.startupAt = Date.now();
469
+ this.runningTimes = (await this.nodeContext.get('runningTimes', 0)) + 1;
470
+ this.runningDays = await this.nodeContext.get('runningDays', 0);
471
+ await this.nodeContext.set('runningTimes', this.runningTimes);
472
+ await this.nodeContext.set('runningDays', this.runningDays);
473
+ await this.nodeContext.set('lastStartupAt', this.startupAt);
474
+ }
457
475
  this.initialPort = this.port = getIntParameter('port') ?? (await this.nodeContext.get('matterport', 5540)) ?? 5540;
458
476
  this.initialPasscode = this.passcode =
459
477
  getIntParameter('passcode') ?? (await this.nodeContext.get('matterpasscode')) ?? PaseClient.generateRandomPasscode(this.environment.get(Crypto));
@@ -723,8 +741,7 @@ export class Matterbridge extends EventEmitter {
723
741
  this.log.debug(`Parsing plugin ${plg}${plugin.name}${db} from path ${CYAN}${plugin.path}${db} ` +
724
742
  `with version ${CYAN}${plugin.version}${db} type ${CYAN}${plugin.type}${db} local ${CYAN}${isLocal}${db} linked ${CYAN}${isLinked}${db} ` +
725
743
  `private ${CYAN}${plugin.private}${db} tarball ${CYAN}${plugin.tarballPath}${db}.`);
726
- if ((isLocal && fs.existsSync(plugin.path) && !isLinked && !hasAnyParameter('add', 'remove', 'enable', 'disable', 'reset', 'factoryreset', 'systemcheck')) ||
727
- process.env.MATTERBRIDGE_LINK_LOCAL_PLUGINS === 'jest') {
744
+ if ((isLocal && fs.existsSync(plugin.path) && !isLinked && !this.isShutdownCommand) || process.env.MATTERBRIDGE_LINK_LOCAL_PLUGINS === 'jest') {
728
745
  const { execSync } = await import('node:child_process');
729
746
  try {
730
747
  execSync(isBun() ? 'bun link matterbridge --silent' : 'npm link matterbridge --no-fund --no-audit --silent', { cwd: path.dirname(plugin.path) });
@@ -737,8 +754,7 @@ export class Matterbridge extends EventEmitter {
737
754
  continue;
738
755
  }
739
756
  }
740
- if ((!isLocal && !fs.existsSync(plugin.path) && !hasAnyParameter('add', 'remove', 'enable', 'disable', 'reset', 'factoryreset', 'systemcheck')) ||
741
- process.env.MATTERBRIDGE_REINSTALL_PLUGINS === 'jest') {
757
+ if ((!isLocal && !fs.existsSync(plugin.path) && !this.isShutdownCommand) || process.env.MATTERBRIDGE_REINSTALL_PLUGINS === 'jest') {
742
758
  const { execSync } = await import('node:child_process');
743
759
  const sudo = hasParameter('sudo') || (process.platform !== 'win32' && !hasParameter('docker') && !hasParameter('nosudo') && !process.env.PATH?.includes('/.nvm/versions/node/'));
744
760
  try {
@@ -1404,6 +1420,14 @@ export class Matterbridge extends EventEmitter {
1404
1420
  }
1405
1421
  }
1406
1422
  this.server.request({ type: 'frontend_matterbridgestatusupdate', src: 'matterbridge', dst: 'frontend', params: { status: (this.bridgeStatus = 'stopped') } });
1423
+ if (!this.isShutdownCommand) {
1424
+ this.shutdownAt = Date.now();
1425
+ this.runningDays = this.runningDays + Math.floor((this.shutdownAt - this.startupAt) / (1000 * 60 * 60 * 24));
1426
+ await this.nodeContext?.set('runningDays', this.runningDays);
1427
+ await this.nodeContext?.set('lastShutdownAt', this.shutdownAt);
1428
+ this.log.info(`Matterbridge has run ${this.runningTimes} times for a total of ${this.runningDays} days.`);
1429
+ this.log.info(`Matterbridge last started at ${new Date(this.startupAt).toLocaleString()} and shut down at ${new Date(this.shutdownAt).toLocaleString()}`);
1430
+ }
1407
1431
  await this.frontend.stop();
1408
1432
  this.frontend.destroy();
1409
1433
  this.plugins.destroy();
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@matterbridge/core",
3
- "version": "3.9.3",
3
+ "version": "3.9.4-dev-20260706-08fe8ef",
4
4
  "description": "Matterbridge core library",
5
5
  "author": "https://github.com/Luligu",
6
6
  "homepage": "https://matterbridge.io/",
@@ -129,11 +129,11 @@
129
129
  "CHANGELOG.md"
130
130
  ],
131
131
  "dependencies": {
132
- "@matter/main": "0.17.4-alpha.0-20260628-67a669f75",
133
- "@matterbridge/dgram": "3.9.3",
134
- "@matterbridge/thread": "3.9.3",
135
- "@matterbridge/types": "3.9.3",
136
- "@matterbridge/utils": "3.9.3",
132
+ "@matter/main": "0.17.4",
133
+ "@matterbridge/dgram": "3.9.4-dev-20260706-08fe8ef",
134
+ "@matterbridge/thread": "3.9.4-dev-20260706-08fe8ef",
135
+ "@matterbridge/types": "3.9.4-dev-20260706-08fe8ef",
136
+ "@matterbridge/utils": "3.9.4-dev-20260706-08fe8ef",
137
137
  "escape-html": "1.0.3",
138
138
  "express": "5.2.1",
139
139
  "express-rate-limit": "8.5.2",