@@ -60,25 +60,6 @@ class HttpServerCommand extends Command
60
60
*/
61
61
protected $ config ;
62
62
63
- /**
64
- * A manager to handle pid about the application.
65
- *
66
- * @var PidManager
67
- */
68
- protected $ pidManager ;
69
-
70
- /**
71
- * Create a an new HttpServerCommand instance.
72
- *
73
- * @param PidManager $pidManager
74
- */
75
- public function __construct (PidManager $ pidManager )
76
- {
77
- parent ::__construct ();
78
-
79
- $ this ->pidManager = $ pidManager ;
80
- }
81
-
82
63
/**
83
64
* Execute the console command.
84
65
*
@@ -170,7 +151,7 @@ protected function stop()
170
151
171
152
// I don't known why Swoole didn't trigger "onShutdown" after sending SIGTERM.
172
153
// So we should manually remove the pid file.
173
- $ this ->pidManager ->delete ();
154
+ $ this ->laravel -> make (PidManager::class) ->delete ();
174
155
175
156
$ this ->info ('> success ' );
176
157
}
@@ -229,7 +210,10 @@ protected function showInfos()
229
210
$ workerNum = Arr::get ($ this ->config , 'server.options.worker_num ' );
230
211
$ taskWorkerNum = Arr::get ($ this ->config , 'server.options.task_worker_num ' );
231
212
$ isWebsocket = Arr::get ($ this ->config , 'websocket.enabled ' );
213
+ $ hasTaskWorker = $ isWebsocket || Arr::get ($ this ->config , 'queue.default ' ) === 'swoole ' ;
232
214
$ logFile = Arr::get ($ this ->config , 'server.options.log_file ' );
215
+ $ pidManager = $ this ->laravel ->make (PidManager::class);
216
+ [$ masterPid , $ managerPid ] = $ pidManager ->read ();
233
217
234
218
$ table = [
235
219
['PHP Version ' , 'Version ' => phpversion ()],
@@ -240,9 +224,10 @@ protected function showInfos()
240
224
['Server Status ' , $ isRunning ? 'Online ' : 'Offline ' ],
241
225
['Reactor Num ' , $ reactorNum ],
242
226
['Worker Num ' , $ workerNum ],
243
- ['Task Worker Num ' , $ isWebsocket ? $ taskWorkerNum : 0 ],
227
+ ['Task Worker Num ' , $ hasTaskWorker ? $ taskWorkerNum : 0 ],
244
228
['Websocket Mode ' , $ isWebsocket ? 'On ' : 'Off ' ],
245
- ['PID ' , $ isRunning ? implode (', ' , $ this ->pidManager ->read ()) : 'None ' ],
229
+ ['Master PID ' , $ isRunning ? $ masterPid : 'None ' ],
230
+ ['Manager PID ' , $ isRunning && $ managerPid ? $ managerPid : 'None ' ],
246
231
['Log Path ' , $ logFile ],
247
232
];
248
233
@@ -294,9 +279,9 @@ protected function getHotReloadProcess($server)
294
279
*/
295
280
public function isRunning ()
296
281
{
297
- $ pids = $ this ->pidManager ->read ();
282
+ $ pids = $ this ->laravel -> make (PidManager::class) ->read ();
298
283
299
- if ([] === $ pids ) {
284
+ if (! count ( $ pids) ) {
300
285
return false ;
301
286
}
302
287
@@ -322,7 +307,7 @@ public function isRunning()
322
307
protected function killProcess ($ sig , $ wait = 0 )
323
308
{
324
309
Process::kill (
325
- Arr::first ($ this ->pidManager ->read ()),
310
+ Arr::first ($ this ->laravel -> make (PidManager::class) ->read ()),
326
311
$ sig
327
312
);
328
313
0 commit comments