diff --git a/src/services/helpers/utilsWrapper.ts b/src/services/helpers/utilsWrapper.ts index 35cefc17..0dc61d63 100644 --- a/src/services/helpers/utilsWrapper.ts +++ b/src/services/helpers/utilsWrapper.ts @@ -2,10 +2,15 @@ import { MainSettings } from "../main/settings.js"; import { StateBundler } from "../storage/stateBundler.js"; export class Utils { + stateBundler: StateBundler settings: MainSettings constructor(settings: MainSettings) { this.settings = settings this.stateBundler = new StateBundler(settings.storageSettings) } + + Stop() { + this.stateBundler.Stop() + } } \ No newline at end of file diff --git a/src/services/main/index.ts b/src/services/main/index.ts index 27516f62..9a83cce2 100644 --- a/src/services/main/index.ts +++ b/src/services/main/index.ts @@ -84,6 +84,7 @@ export default class { this.lnd.Stop() this.applicationManager.Stop() this.paymentManager.Stop() + this.utils.Stop() } StartBeacons() { diff --git a/src/services/storage/stateBundler.ts b/src/services/storage/stateBundler.ts index 3b81e15f..99737833 100644 --- a/src/services/storage/stateBundler.ts +++ b/src/services/storage/stateBundler.ts @@ -33,10 +33,23 @@ export class StateBundler { tlvStorage: TlvFilesStorage reportLog = getLogger({ component: 'stateBundlerReport' }) prevValues: Record = {} + interval: NodeJS.Timeout constructor(settings: StorageSettings) { const bundlerPath = [settings.dataDir, "bundler_events"].filter(s => !!s).join("/") this.tlvStorage = new TlvFilesStorage(bundlerPath) this.tlvStorage.initMeta() + this.interval = setInterval(() => { + const mem = process.memoryUsage() + this.AddValue('_root', 'memory_rss_kb', Math.ceil(mem.rss / 1000 || 0), true) + this.AddValue('_root', 'memory_buffer_kb', Math.ceil(mem.arrayBuffers / 1000 || 0), true) + this.AddValue('_root', 'memory_heap_total_kb', Math.ceil(mem.heapTotal / 1000 || 0), true) + this.AddValue('_root', 'memory_heap_used_kb', Math.ceil(mem.heapUsed / 1000 || 0), true) + this.AddValue('_root', 'memory_external_kb', Math.ceil(mem.external / 1000 || 0), true) + }, 60 * 1000) + } + + Stop() { + clearInterval(this.interval) } async GetBundleMetrics(req: Types.LatestBundleMetricReq): Promise {