Enable coroutine.

This commit is contained in:
李铭昕 2019-06-20 17:29:14 +08:00
parent ddf604bde1
commit e04b44dcf2
3 changed files with 8 additions and 3 deletions

View File

@ -39,12 +39,13 @@
"monolog/monolog": "^1.24"
},
"require-dev": {
"doctrine/common": "@stable",
"friendsofphp/php-cs-fixer": "^2.14",
"malukenho/docheader": "^0.1.6",
"mockery/mockery": "^1.0",
"phpunit/phpunit": "^7.0.0",
"php-di/php-di": "^6.0",
"doctrine/common": "@stable",
"friendsofphp/php-cs-fixer": "^2.14"
"phpunit/phpunit": "^7.0.0",
"swoft/swoole-ide-helper": "^4.3"
},
"replace": {
"hyperf/amqp": "self.version",

View File

@ -371,6 +371,8 @@ abstract class Command extends SymfonyCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
if ($this->coroutine) {
// Enable Coroutine in co environment.
\Swoole\Runtime::enableCoroutine(true);
go(function () {
call([$this, 'handle']);
});

View File

@ -42,6 +42,8 @@ class StartServer extends SymfonyCommand
protected function execute(InputInterface $input, OutputInterface $output)
{
\Swoole\Runtime::enableCoroutine(true);
$this->checkEnvironment($output);
$serverFactory = $this->container->get(ServerFactory::class)