@@ -60,25 +60,6 @@ class HttpServerCommand extends Command
6060     */ 
6161    protected  $ config ;
6262
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- 
8263    /** 
8364     * Execute the console command. 
8465     * 
@@ -170,7 +151,7 @@ protected function stop()
170151
171152        // I don't known why Swoole didn't trigger "onShutdown" after sending SIGTERM. 
172153        // So we should manually remove the pid file. 
173-         $ this  ->pidManager ->delete ();
154+         $ this  ->laravel -> make (PidManager::class) ->delete ();
174155
175156        $ this  ->info ('> success ' );
176157    }
@@ -229,7 +210,10 @@ protected function showInfos()
229210        $ workerNum  = Arr::get ($ this  ->config , 'server.options.worker_num ' );
230211        $ taskWorkerNum  = Arr::get ($ this  ->config , 'server.options.task_worker_num ' );
231212        $ isWebsocket  = Arr::get ($ this  ->config , 'websocket.enabled ' );
213+         $ hasTaskWorker  = $ isWebsocket  || Arr::get ($ this  ->config , 'queue.default ' ) === 'swoole ' ;
232214        $ logFile  = Arr::get ($ this  ->config , 'server.options.log_file ' );
215+         $ pidManager  = $ this  ->laravel ->make (PidManager::class);
216+         [$ masterPid , $ managerPid ] = $ pidManager ->read ();
233217
234218        $ table  = [
235219            ['PHP Version ' , 'Version '  => phpversion ()],
@@ -240,9 +224,10 @@ protected function showInfos()
240224            ['Server Status ' , $ isRunning  ? 'Online '  : 'Offline ' ],
241225            ['Reactor Num ' , $ reactorNum ],
242226            ['Worker Num ' , $ workerNum ],
243-             ['Task Worker Num ' , $ isWebsocket   ? $ taskWorkerNum  : 0 ],
227+             ['Task Worker Num ' , $ hasTaskWorker   ? $ taskWorkerNum  : 0 ],
244228            ['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 ' ],
246231            ['Log Path ' , $ logFile ],
247232        ];
248233
@@ -294,9 +279,9 @@ protected function getHotReloadProcess($server)
294279     */ 
295280    public  function  isRunning ()
296281    {
297-         $ pids  = $ this  ->pidManager ->read ();
282+         $ pids  = $ this  ->laravel -> make (PidManager::class) ->read ();
298283
299-         if  ([] ===  $ pids ) {
284+         if  (!  count ( $ pids) ) {
300285            return  false ;
301286        }
302287
@@ -322,7 +307,7 @@ public function isRunning()
322307    protected  function  killProcess ($ sig , $ wait  = 0 )
323308    {
324309        Process::kill (
325-             Arr::first ($ this  ->pidManager ->read ()),
310+             Arr::first ($ this  ->laravel -> make (PidManager::class) ->read ()),
326311            $ sig
327312        );
328313
0 commit comments