1 | <?php |
||
21 | class Server |
||
22 | { |
||
23 | /** |
||
24 | * @var Application |
||
25 | */ |
||
26 | protected $application; |
||
27 | |||
28 | /** |
||
29 | * @var \FastD\Swoole\Server |
||
30 | */ |
||
31 | protected $server; |
||
32 | |||
33 | /** |
||
34 | * Server constructor. |
||
35 | * |
||
36 | * @param Application $application |
||
37 | */ |
||
38 | 1 | public function __construct(Application $application) |
|
39 | { |
||
40 | 1 | $application->register(new SwooleServiceProvider()); |
|
41 | |||
42 | 1 | $server = config()->get('server.class', HTTPServer::class); |
|
43 | |||
44 | 1 | $this->server = $server::createServer( |
|
45 | 1 | $application->getName(), |
|
46 | 1 | config()->get('server.host'), |
|
47 | 1 | config()->get('server.options', []) |
|
48 | 1 | ); |
|
49 | |||
50 | 1 | $this->initListeners(); |
|
51 | 1 | $this->initProcesses(); |
|
52 | 1 | } |
|
53 | |||
54 | /** |
||
55 | * @return swoole_server |
||
56 | */ |
||
57 | public function getSwoole() |
||
61 | |||
62 | /** |
||
63 | * @return Swoole\Server |
||
64 | */ |
||
65 | 1 | public function bootstrap() |
|
69 | |||
70 | /** |
||
71 | * @return $this |
||
72 | */ |
||
73 | 1 | public function initListeners() |
|
86 | |||
87 | /** |
||
88 | * @return $this |
||
89 | */ |
||
90 | 1 | public function initProcesses() |
|
99 | |||
100 | /** |
||
101 | * @return $this |
||
102 | */ |
||
103 | public function daemon() |
||
109 | |||
110 | /** |
||
111 | * @return $this |
||
112 | */ |
||
113 | public function useQueue() |
||
123 | |||
124 | /** |
||
125 | * @return int |
||
126 | */ |
||
127 | public function start() |
||
135 | |||
136 | /** |
||
137 | * @return int |
||
138 | */ |
||
139 | public function stop() |
||
143 | |||
144 | /** |
||
145 | * @return int |
||
146 | */ |
||
147 | public function restart() |
||
151 | |||
152 | /** |
||
153 | * @return int |
||
154 | */ |
||
155 | public function reload() |
||
159 | |||
160 | /** |
||
161 | * @return int |
||
162 | */ |
||
163 | public function status() |
||
167 | |||
168 | /** |
||
169 | * @param array $dir |
||
170 | * |
||
171 | * @return int |
||
172 | */ |
||
173 | public function watch(array $dir = ['.']) |
||
177 | |||
178 | /** |
||
179 | * @param InputInterface $input |
||
180 | */ |
||
181 | public function run(InputInterface $input) |
||
213 | } |
||
214 |