use Workerman\Worker;
use Workerman\Connection\TcpConnection;
require_once __DIR__ . '/vendor/autoload.php';
$worker = new Worker('websocket://0.0.0.0:8484');
$worker->count = 1;// 这里只有1个进程
$worker->onWorkerStart = function($worker){};
$worker->onConnect = function(TcpConnection $connection){};
$worker->onMessage = function(TcpConnection $connection, $data){};
$worker->onClose = function(TcpConnection $connection){};
$worker->onError = function(TcpConnection $connection, $code, $msg){};
// 运行worker
Worker::runAll();
当 $worker->count = 1 时,workerman是不是仍然会启动 1个主进程、1个子进程 ?
主进程 管理 子进程(包括守护子进程之类),而 onWorkerStart、onConnect、onMessage、onClose、onError 等是在子进程里运算的?
按这意思,
count
是子进程数量。谢谢