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 | 1 | */ |
|
38 | public function __construct(Application $application) |
||
39 | 1 | { |
|
40 | $application->register(new SwooleServiceProvider()); |
||
41 | 1 | ||
42 | $server = config()->get('server.class', HTTPServer::class); |
||
43 | 1 | ||
44 | 1 | $this->server = $server::createServer( |
|
45 | 1 | $application->getName(), |
|
46 | 1 | config()->get('server.host'), |
|
47 | 1 | config()->get('server.options', []) |
|
48 | ); |
||
49 | 1 | ||
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 | public function initListeners() |
||
86 | 1 | ||
87 | 1 | /** |
|
88 | 1 | * @return $this |
|
89 | 1 | */ |
|
90 | 1 | public function initProcesses() |
|
99 | |||
100 | 1 | /** |
|
101 | * @return $this |
||
102 | 1 | */ |
|
103 | 1 | public function daemon() |
|
109 | |||
110 | /** |
||
111 | * @return int |
||
112 | */ |
||
113 | public function start() |
||
121 | |||
122 | /** |
||
123 | * @return int |
||
124 | */ |
||
125 | public function stop() |
||
129 | |||
130 | /** |
||
131 | * @return int |
||
132 | */ |
||
133 | public function restart() |
||
137 | |||
138 | /** |
||
139 | * @return int |
||
140 | */ |
||
141 | public function reload() |
||
145 | |||
146 | /** |
||
147 | * @return int |
||
148 | */ |
||
149 | public function status() |
||
153 | |||
154 | /** |
||
155 | * @param array $dir |
||
156 | * |
||
157 | * @return int |
||
158 | */ |
||
159 | public function watch(array $dir = ['.']) |
||
163 | |||
164 | /** |
||
165 | * @param InputInterface $input |
||
166 | */ |
||
167 | public function run(InputInterface $input) |
||
192 | } |
||
193 |