File tree 2 files changed +32
-2
lines changed
2 files changed +32
-2
lines changed Original file line number Diff line number Diff line change @@ -13,6 +13,13 @@ class SupervisorOutOfMemory
13
13
*/
14
14
public $ supervisor ;
15
15
16
+ /**
17
+ * The memory usage that exceeded the allowable limit.
18
+ *
19
+ * @var int|float
20
+ */
21
+ public $ memoryUsage ;
22
+
16
23
/**
17
24
* Create a new event instance.
18
25
*
@@ -23,4 +30,27 @@ public function __construct(Supervisor $supervisor)
23
30
{
24
31
$ this ->supervisor = $ supervisor ;
25
32
}
33
+
34
+ /**
35
+ * Get the memory usage that triggered the event.
36
+ *
37
+ * @return int|float
38
+ */
39
+ public function getMemoryUsage ()
40
+ {
41
+ return $ this ->memoryUsage ?? $ this ->supervisor ->memoryUsage ();
42
+ }
43
+
44
+ /**
45
+ * Set the memory usage that was recorded when the event was dispatched.
46
+ *
47
+ * @param int|float $memoryUsage
48
+ * @return $this
49
+ */
50
+ public function setMemoryUsage ($ memoryUsage )
51
+ {
52
+ $ this ->memoryUsage = $ memoryUsage ;
53
+
54
+ return $ this ;
55
+ }
26
56
}
Original file line number Diff line number Diff line change @@ -17,8 +17,8 @@ public function handle(SupervisorLooped $event)
17
17
{
18
18
$ supervisor = $ event ->supervisor ;
19
19
20
- if ($ supervisor ->memoryUsage () > $ supervisor ->options ->memory ) {
21
- event (new SupervisorOutOfMemory ($ supervisor ));
20
+ if (( $ memoryUsage = $ supervisor ->memoryUsage () ) > $ supervisor ->options ->memory ) {
21
+ event (( new SupervisorOutOfMemory ($ supervisor))-> setMemoryUsage ( $ memoryUsage ));
22
22
23
23
$ supervisor ->terminate (12 );
24
24
}
You can’t perform that action at this time.
0 commit comments