diff --git a/http-server/ServerManager.php b/http-server/ServerManager.php index eb33d800..719bf633 100644 --- a/http-server/ServerManager.php +++ b/http-server/ServerManager.php @@ -68,9 +68,10 @@ class ServerManager */ protected static function createProcess($process, $application, $pool, $workerId) { + $application->set($pool->getProcess($workerId)); $process = new $process($application); $application->debug(sprintf('Worker #%d is running.', $workerId)); - return $process->start($pool->getProcess($workerId)); + return $process->start(); } diff --git a/system/Process/Process.php b/system/Process/Process.php index e0560b02..6519fdf1 100644 --- a/system/Process/Process.php +++ b/system/Process/Process.php @@ -38,13 +38,11 @@ abstract class Process extends Component /** - * @param $process */ - protected function start($process) + protected function start() { - do { - $this->onHandler($process); - } while (true); + $_process = new \Swoole\Process([$this, 'onHandler'], false, null, true); + $_process->start(); } }