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