diff --git a/HttpServer/Server.php b/HttpServer/Server.php index 10f2ed0c..1b45a3cf 100644 --- a/HttpServer/Server.php +++ b/HttpServer/Server.php @@ -214,7 +214,11 @@ class Server extends Application if (!is_string($process)) { continue; } - $system = new $process(Snowflake::app(), $name); + $is_enable_coroutine = true; + if (is_array($process)) { + [$process, $is_enable_coroutine] = $process; + } + $system = new $process(Snowflake::app(), $name, $is_enable_coroutine); $this->baseServer->addProcess($system); $application->set($process, $system); } diff --git a/System/Process/Process.php b/System/Process/Process.php index 5358a0a6..74e2d443 100644 --- a/System/Process/Process.php +++ b/System/Process/Process.php @@ -26,9 +26,10 @@ abstract class Process extends \Swoole\Process * Process constructor. * @param $application * @param $name + * @param bool $enable_coroutine * @throws \Exception */ - public function __construct($application, $name) + public function __construct($application, $name, $enable_coroutine = true) { $class = get_called_class(); parent::__construct(function ($process) use ($name, $class) { @@ -36,7 +37,7 @@ abstract class Process extends \Swoole\Process $this->name('Processes: ' . $class . '::class'); } $this->onHandler($process); - }, false, 1, true); + }, false, 1, $enable_coroutine); $this->application = $application; Snowflake::setWorkerId($this->pid); }