× 警告!旧版文档已经暂停维护,请查看新版文档。点击前往新版文档

Server::$worker_id

得到当前Worker进程的编号,包括Task进程。

int $server->worker_id;

这个属性与onWorkerStart时的$worker_id是相同的。

  • Worker进程编号范围是[0, $serv->setting['worker_num']-1]
  • Task进程编号范围是[$serv->setting['worker_num'], $serv->setting['worker_num'] + $serv->setting['task_worker_num']]

工作进程重启后worker_id的值是不变的


  • 覃祺华

    是否有误? 应该改为:Worker进程ID范围是[0, $serv->setting['worker_num']-1)

  • 谁伴我闯荡

    楼上集合没学好,请注意[0, $serv->setting['worker_num'])右侧是圆括号不是中括号

  • 年轻就该奋斗

    Task 感觉是 [$serv->setting['worker_num'], $serv->setting['worker_num'] + $serv->setting['task_worker_num']-1]

  • 水滴月

    Worker进程编号范围是:0setting['worker_num'] setting['task_worker_num']-1