feat(heartbeat): add process memory and backup health checks

This commit is contained in:
William Valentin
2026-02-16 13:50:39 -08:00
parent 8684c3a07d
commit 07340ff0af
11 changed files with 282 additions and 8 deletions
+4
View File
@@ -3,6 +3,7 @@ import type { BackupConfig } from '../config/schema.js';
import type { OutboundMessage } from '../channels/types.js';
import { parseDuration } from '../session/index.js';
import { runBackupSnapshot } from './run.js';
import { initBackupHealth, markBackupFailure, markBackupSuccess } from './status.js';
interface ChannelLookup {
get(name: string): { send(peerId: string, message: OutboundMessage): Promise<void> } | undefined;
@@ -28,6 +29,7 @@ export class BackupScheduler {
}
start(): void {
initBackupHealth(this.deps.backupConfig.enabled);
if (!this.deps.backupConfig.enabled) {
return;
}
@@ -92,10 +94,12 @@ export class BackupScheduler {
backupConfig: this.deps.backupConfig,
});
console.log(`Backup completed: ${result.archivePath}${result.uploaded && result.remotePath ? ` -> ${result.remotePath}` : ''}`);
markBackupSuccess();
await this.handleSuccess();
} catch (error) {
const message = error instanceof Error ? error.message : String(error);
console.error(`Backup failed: ${message}`);
markBackupFailure(message);
await this.handleFailure(message);
} finally {
this.running = false;