feat(heartbeat): add process memory and backup health checks
This commit is contained in:
@@ -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;
|
||||
|
||||
Reference in New Issue
Block a user