<?php
Swoole\Process\Pool->getProcess ( int $worker_id = 0 )
The worker ID
Swoole\Process
Get the process by $worker_id
. By default, it return the current process.
<?php
$workerNum = 10;
$pool = new Swoole\Process\Pool($workerNum);
$pool->on("WorkerStart", function ($pool, $workerId) {
$process = $pool->getProcess();
$process->exec("/bin/sh", ["ls", '-l']);
});
$pool->on("WorkerStop", function ($pool, $workerId) {
echo "Worker#{$workerId} is stopped\n";
});
$pool->start();