diff --git a/Server/Abstracts/CustomProcess.php b/Server/Abstracts/CustomProcess.php index 108f2823..cd88e86c 100644 --- a/Server/Abstracts/CustomProcess.php +++ b/Server/Abstracts/CustomProcess.php @@ -54,12 +54,22 @@ abstract class CustomProcess implements \Server\SInterface\CustomProcess } }); } else { - go(function () use ($process) { + Coroutine::create(function () use ($process) { + /** @var Coroutine\Socket $message */ + $message = $process->exportSocket(); + error($message->recv()); + $process->exit(0); + }); + Coroutine::create(function () use ($process) { $data = Coroutine::waitSignal(SIGTERM | SIGKILL, -1); if ($data) { $lists = Kiri::app()->getProcess(); - foreach ($lists as $process) { - $process->exit(0); + foreach ($lists as $name => $process) { + foreach ($process as $item) { + /** @var Coroutine\Socket $export */ + $export = $item->exportSocket(); + $export->send([$name => 'exit']); + } } } }); diff --git a/Server/ServerManager.php b/Server/ServerManager.php index fce9a909..02acfee3 100644 --- a/Server/ServerManager.php +++ b/Server/ServerManager.php @@ -203,7 +203,6 @@ class ServerManager * @param array $config * @param int $daemon * @throws ConfigException - * @throws NotFindClassException * @throws ReflectionException * @throws Exception */ diff --git a/System/Application.php b/System/Application.php index 93518405..99a9a9f0 100644 --- a/System/Application.php +++ b/System/Application.php @@ -50,7 +50,7 @@ class Application extends BaseApplication public string $state = ''; - /** @var array */ + /** @var array> */ private array $_process = []; @@ -88,7 +88,10 @@ class Application extends BaseApplication */ public function addProcess(string $class, Process $process) { - $this->_process[$class] = $process; + if (isset($this->_process[$class])) { + $this->_process[$class] = []; + } + $this->_process[$class][] = $process; }