count

Description:

int Worker::$count

Sets how many processes to start for the current Worker instance. The default is 1 if not set.

For how to set the number of processes, please refer to here.

Note: This property must be set before Worker::runAll(); is executed to take effect. This feature is not supported on Windows systems.

Example

use Workerman\Worker;
require_once __DIR__ . '/vendor/autoload.php';

$worker = new Worker('websocket://0.0.0.0:8484');
// Start 8 processes, listening on port 8484, providing services using the websocket protocol
$worker->count = 8;
$worker->onWorkerStart = function($worker)
{
    echo "Worker starting...\n";
};
// Run the worker
Worker::runAll();