This commit is contained in:
2021-08-18 13:48:34 +08:00
parent be67fdf155
commit 6d4e21d006
3 changed files with 17 additions and 8 deletions
+3 -4
View File
@@ -270,7 +270,6 @@ class ServerManager
* @param int $port
* @param int $mode
* @param array $settings
* @throws NotFindClassException
* @throws ReflectionException
* @throws ConfigException
*/
@@ -300,7 +299,7 @@ class ServerManager
return;
}
while ($this->checkPortIsAlready($port)) {
Process::kill($pid,SIGTERM);
Process::kill($pid, SIGTERM);
usleep(300);
}
}
@@ -329,7 +328,6 @@ class ServerManager
/**
* @param string $type
* @param array $settings
* @throws NotFindClassException
* @throws ReflectionException
* @throws Exception
*/
@@ -339,13 +337,14 @@ class ServerManager
$this->addTaskListener($settings['events']);
}
$this->addServiceEvents($settings['events'] ?? [], $this->server);
Kiri::getDi()->setBindings(SwooleServerInterface::class,
$this->server);
}
/**
* @param array $events
* @param Server|Port $server
* @throws NotFindClassException
* @throws ReflectionException
*/
private function addServiceEvents(array $events, Server|Port $server)
+14
View File
@@ -0,0 +1,14 @@
<?php
namespace Server;
use Swoole\Server;
/**
* @mixin Server
*/
interface SwooleServerInterface
{
}
-4
View File
@@ -201,10 +201,6 @@ class Container extends BaseObject implements ContainerInterface
foreach ($this->getPropertyNote($reflect) as $property => $inject) {
/** @var Inject $inject */
$inject->execute($object, $property);
if ($object::class == Server::class){
var_dump($object, $property);
}
}
return $object;
}