This repository was archived by the owner on Jun 3, 2024. It is now read-only.
File tree Expand file tree Collapse file tree 1 file changed +14
-7
lines changed
Expand file tree Collapse file tree 1 file changed +14
-7
lines changed Original file line number Diff line number Diff line change @@ -26,9 +26,16 @@ public function serverIsRunning(): bool
2626 return (bool ) $ masterProcessId ;
2727 }
2828
29- public function writeProcessId ($ pid )
29+ public function writeProcessId ()
3030 {
31- $ this ->serverStateFile ->writeProcessId ($ pid );
31+ $ pid = @file_get_contents (config ('workerman.http.pidFile ' ));
32+
33+ if ($ pid ) {
34+ $ this ->serverStateFile ->writeProcessId ($ pid );
35+ return true ;
36+ }
37+
38+ return false ;
3239 }
3340
3441 public function getServer ($ mode , array $ args = [])
@@ -74,6 +81,8 @@ public function startServer()
7481
7582 $ server ->start ();
7683
84+ $ server ->waitUntil ([$ this , 'writeProcessId ' ]);
85+
7786 $ this ->writeProcessId ($ server ->getPid ());
7887
7988 return $ server ;
@@ -90,13 +99,11 @@ public function startDaemonServer()
9099 return ;
91100 }
92101
93- $ server = $ this ->getServer ('start ' );
94-
95- $ server ->run ();
102+ $ server = $ this ->getServer ('start ' , ['-d ' ]);
96103
97- $ pid = file_get_contents ( config ( ' workerman.gatewayworker.http.pid_file ' ) );
104+ $ server -> start ( );
98105
99- $ this -> writeProcessId ( $ pid );
106+ $ server -> waitUntil ([ $ this , ' writeProcessId ' ] );
100107
101108 return $ server ;
102109 }
You can’t perform that action at this time.
0 commit comments