File tree Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Expand file tree Collapse file tree 1 file changed +7
-3
lines changed Original file line number Diff line number Diff line change @@ -44,14 +44,18 @@ class RtsMon {
44
44
45
45
const aboveThreshold : boolean = memoryUsageMB >= this . options . thresholdMib ;
46
46
if ( aboveThreshold === true ) {
47
- this . sendSignal ( pid ) ;
47
+ await this . sendSignal ( pid ) ;
48
48
this . currentIntervalSeconds *= 2 ;
49
49
Program . log (
50
50
`RSS ${ memoryUsageMB . toFixed ( 1 ) } MB >= threshold (${ this . options . thresholdMib } MiB). Increasing interval to ${
51
51
this . currentIntervalSeconds
52
52
} s`
53
53
) ;
54
54
} else {
55
+ if ( this . currentIntervalSeconds > this . options . intervalSeconds ) {
56
+ // Memory usage came back down below the threshold since last check. Collect one more report.
57
+ await this . sendSignal ( pid ) ;
58
+ }
55
59
Program . log ( `RSS ${ memoryUsageMB . toFixed ( 1 ) } MiB (below threshold ${ this . options . thresholdMib } MiB).` ) ;
56
60
this . resetDelay ( ) ;
57
61
}
@@ -67,9 +71,9 @@ class RtsMon {
67
71
this . currentIntervalSeconds = this . options . intervalSeconds ;
68
72
}
69
73
70
- private sendSignal ( pid : number ) : void {
74
+ private async sendSignal ( pid : number ) : Promise < void > {
71
75
try {
72
- this . runCommand ( "kill" , [ "-SIGUSR2" , String ( pid ) ] ) ;
76
+ await this . runCommand ( "kill" , [ "-SIGUSR2" , String ( pid ) ] ) ;
73
77
Program . log ( `Sent SIGUSR2 to pid ${ pid } ` ) ;
74
78
} catch ( e ) {
75
79
Program . logError ( `Failed to send SIGUSR2 to pid ${ pid } : ${ ( e as Error ) . message } ` ) ;
You can’t perform that action at this time.
0 commit comments