This commit is contained in:
2021-08-19 18:27:19 +08:00
parent fedef53f93
commit ccba377f13
3 changed files with 18 additions and 6 deletions
+13 -3
View File
@@ -54,12 +54,22 @@ abstract class CustomProcess implements \Server\SInterface\CustomProcess
} }
}); });
} else { } 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); $data = Coroutine::waitSignal(SIGTERM | SIGKILL, -1);
if ($data) { if ($data) {
$lists = Kiri::app()->getProcess(); $lists = Kiri::app()->getProcess();
foreach ($lists as $process) { foreach ($lists as $name => $process) {
$process->exit(0); foreach ($process as $item) {
/** @var Coroutine\Socket $export */
$export = $item->exportSocket();
$export->send([$name => 'exit']);
}
} }
} }
}); });
-1
View File
@@ -203,7 +203,6 @@ class ServerManager
* @param array $config * @param array $config
* @param int $daemon * @param int $daemon
* @throws ConfigException * @throws ConfigException
* @throws NotFindClassException
* @throws ReflectionException * @throws ReflectionException
* @throws Exception * @throws Exception
*/ */
+5 -2
View File
@@ -50,7 +50,7 @@ class Application extends BaseApplication
public string $state = ''; public string $state = '';
/** @var array<Process> */ /** @var array<array<Process>> */
private array $_process = []; private array $_process = [];
@@ -88,7 +88,10 @@ class Application extends BaseApplication
*/ */
public function addProcess(string $class, Process $process) public function addProcess(string $class, Process $process)
{ {
$this->_process[$class] = $process; if (isset($this->_process[$class])) {
$this->_process[$class] = [];
}
$this->_process[$class][] = $process;
} }