This commit is contained in:
2020-09-01 15:51:34 +08:00
parent dae8325024
commit d21d5ede91
2 changed files with 6 additions and 3 deletions
+6 -2
View File
@@ -27,8 +27,12 @@ class Processes extends Component
*/
public function initCore()
{
$server = new Pool($this->size(), SWOOLE_IPC_UNIXSOCK);
$server->on('workerStart', function (Pool $pool, int $workerId) {
$application = Snowflake::get();
$server = $application->set(Pool::class, new Pool($this->size(), SWOOLE_IPC_UNIXSOCK));
$server->on('workerStart', function (Pool $pool, int $workerId) use ($application) {
if (is_string($this->processes[$workerId]) && class_exists($this->processes[$workerId])) {
$application->set($this->processes[$workerId], $workerId);
}
ServerManager::create($pool, $this->processes[$workerId], $workerId);
});
$server->on('workerStop', function (Pool $pool, int $workerId) {