fix(ResourceMonitoringService): initialize fd check time and count on start
This commit is contained in:
parent
a99288f25a
commit
df83e66d5c
1 changed files with 8 additions and 6 deletions
|
|
@ -45,7 +45,7 @@ class ResourceMonitoringService {
|
|||
private maxHistorySize = 300; // Keep 5 minutes at 1s intervals
|
||||
private lastCpuUsage = process.cpuUsage();
|
||||
private lastTimestamp = Date.now();
|
||||
private lastFdCheckTime = 0;
|
||||
private lastFdCheckTime = Date.now();
|
||||
private fdCheckIntervalMs = 5000; // Check file descriptors every 5 seconds
|
||||
private cacheFileCount: number | null = null;
|
||||
|
||||
|
|
@ -73,6 +73,12 @@ class ResourceMonitoringService {
|
|||
this.lastCpuUsage = process.cpuUsage();
|
||||
this.lastTimestamp = Date.now();
|
||||
|
||||
// Initialize file descriptor count on start
|
||||
this.updateFileDescriptorCount().catch(() => {
|
||||
// Ignore errors during initialization
|
||||
});
|
||||
this.lastFdCheckTime = Date.now();
|
||||
|
||||
this.monitoringInterval = setInterval(() => {
|
||||
this.collectResourceUsage();
|
||||
}, this.intervalMs);
|
||||
|
|
@ -130,11 +136,7 @@ class ResourceMonitoringService {
|
|||
},
|
||||
};
|
||||
|
||||
// Initialize file descriptor count on start
|
||||
this.updateFileDescriptorCount().catch(() => {
|
||||
// Ignore errors during initialization
|
||||
});
|
||||
|
||||
// Use cached file descriptor count to avoid lsof command leak
|
||||
if (this.cacheFileCount !== null) {
|
||||
usage.fileDescriptors = this.cacheFileCount;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue