File tree Expand file tree Collapse file tree 1 file changed +15
-0
lines changed
packages/core/src/shared/utilities Expand file tree Collapse file tree 1 file changed +15
-0
lines changed Original file line number Diff line number Diff line change @@ -66,6 +66,12 @@ export const eof = Symbol('EOF')
66
66
67
67
class ChildProcessTracker extends Map < number , ChildProcess > {
68
68
static pollingInterval : number = 1000
69
+ static thresholds : { memory : number ; cpu : number ; time : number } = {
70
+ memory : 100 * 1024 * 1024 , // 100 MB
71
+ cpu : 50 ,
72
+ time : 30 * 1000 , // 30 seconds
73
+ }
74
+
69
75
#processPoller: PollingSet < number >
70
76
71
77
public constructor ( ) {
@@ -96,6 +102,15 @@ class ChildProcessTracker extends Map<number, ChildProcess> {
96
102
if ( this . has ( pid ) ) {
97
103
const stats = await pidusage ( pid )
98
104
getLogger ( ) . debug ( `stats for ${ pid } : %O` , stats )
105
+ if ( stats . memory > ChildProcessTracker . thresholds . memory ) {
106
+ getLogger ( ) . warn ( `Process ${ pid } exceeded memory threshold: ${ stats . memory } ` )
107
+ }
108
+ if ( stats . cpu > ChildProcessTracker . thresholds . cpu ) {
109
+ getLogger ( ) . warn ( `Process ${ pid } exceeded cpu threshold: ${ stats . cpu } ` )
110
+ }
111
+ if ( stats . elapsed > ChildProcessTracker . thresholds . time ) {
112
+ getLogger ( ) . warn ( `Process ${ pid } exceeded time threshold: ${ stats . elapsed } ` )
113
+ }
99
114
} else {
100
115
getLogger ( ) . warn ( `Missing process with id ${ pid } ` )
101
116
}
You can’t perform that action at this time.
0 commit comments