1 | <?php |
||
9 | trait DaemonTrait |
||
10 | { |
||
11 | /** |
||
12 | * @var bool |
||
13 | */ |
||
14 | private $isShutdown = false; |
||
15 | |||
16 | /** |
||
17 | * @var string |
||
18 | */ |
||
19 | private $shutdownMessage = ''; |
||
20 | |||
21 | /** |
||
22 | * @var int |
||
23 | */ |
||
24 | private $requestCount; |
||
25 | |||
26 | /** |
||
27 | * @var int |
||
28 | */ |
||
29 | private $requestLimit; |
||
30 | |||
31 | /** |
||
32 | * @var int |
||
33 | */ |
||
34 | private $memoryLimit; |
||
35 | |||
36 | /** |
||
37 | * @var bool |
||
38 | */ |
||
39 | private $autoShutdown; |
||
40 | |||
41 | /** |
||
42 | * Flags the daemon for shutting down. |
||
43 | * |
||
44 | * @param string $message Optional shutdown message |
||
45 | */ |
||
46 | public function flagShutdown(string $message = null): void |
||
51 | |||
52 | /** |
||
53 | * Loads to configuration from the daemon options and installs signal |
||
54 | * handlers. |
||
55 | * |
||
56 | * @param DaemonOptionsInterface $daemonOptions |
||
57 | */ |
||
58 | private function setupDaemon(DaemonOptionsInterface $daemonOptions): void |
||
73 | |||
74 | /** |
||
75 | * Increments the request count and looks for application errors. |
||
76 | * |
||
77 | * @param int[] $statusCodes The status codes of sent responses |
||
78 | */ |
||
79 | private function considerStatusCodes(array $statusCodes): void |
||
92 | |||
93 | /** |
||
94 | * Installs a handler which throws a ShutdownException upon receiving a |
||
95 | * SIGINT or a SIGALRM. |
||
96 | * |
||
97 | * @throws ShutdownException On receiving a SIGINT or SIGALRM |
||
98 | */ |
||
99 | private function installSignalHandlers(): void |
||
111 | |||
112 | /** |
||
113 | * Checks the current PHP process against the limits specified in a daemon |
||
114 | * options object. This function will also throw an exception if the daemon |
||
115 | * has been flagged for shutdown. |
||
116 | * |
||
117 | * @throws ShutdownException When limits in the daemon options are exceeded |
||
118 | */ |
||
119 | private function checkDaemonLimits(): void |
||
141 | } |
||
142 |