Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php int OpenSwoole\Process\Pool->shutdown()
Shutdown a process pool.
<?php
$workerNum = 10;
$pool = new OpenSwoole\Process\Pool($workerNum);
$pool->on("WorkerStart", function ($pool, $workerId) {
$process = $pool->getProcess();
$process->exec("/bin/sh", ["ls", '-l']);
$process->shutdown();
});
$pool->on("WorkerStop", function ($pool, $workerId) {
echo "Worker#{$workerId} is stopped\n";
});
$pool->start();