Skip to content

Commit

Permalink
修复跨进程变量共享启动时未正常挂起 (#709)
Browse files Browse the repository at this point in the history
* 修复跨进程变量共享启动时未正常挂起

* Update SharedMemoryProcess.php

* 更新 SharedMemoryProcess.php
  • Loading branch information
Eno-CN authored Jul 18, 2024
1 parent 0c21a40 commit c7ed71e
Showing 1 changed file with 10 additions and 0 deletions.
10 changes: 10 additions & 0 deletions src/Components/shared-memory/src/Process/SharedMemoryProcess.php
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
use Imi\Swoole\Process\Annotation\Process;
use Imi\Swoole\Process\BaseProcess;
use Imi\Util\Imi;
use Imi\Util\ImiPriority;
use Yurun\Swoole\SharedMemory\Server;

/**
Expand All @@ -17,6 +18,10 @@ class SharedMemoryProcess extends BaseProcess
{
public function run(\Swoole\Process $process): void
{
$running = true;
\Imi\Event\Event::on('IMI.PROCESS.END', static function () use (&$running) {
$running = false;
}, ImiPriority::IMI_MAX);
$socketFile = Config::get('@app.swooleSharedMemory.socketFile');
if (null === $socketFile)
{
Expand All @@ -34,5 +39,10 @@ public function run(\Swoole\Process $process): void
]);
$server->run();
fwrite(\STDOUT, 'Process [sharedMemory] start' . \PHP_EOL);
/** @phpstan-ignore-next-line */
while ($running)
{
sleep(1);
}
}
}

0 comments on commit c7ed71e

Please sign in to comment.