onWorkerStart

说明:

  1. callback Worker::$onWorkerStart

设置Worker启动时的回调函数,即当Worker启动后立即执行Worker::onWorkerStart成员指定的回调函数

回调函数的参数

$worker

即Worker对象

范例

  1. use Workerman\Worker;
  2. require_once __DIR__ . '/Workerman/Autoloader.php';
  3. $worker = new Worker('websocket://0.0.0.0:8484');
  4. $worker->onWorkerStart = function($worker)
  5. {
  6. echo "Worker starting...\n";
  7. };
  8. // 运行worker
  9. Worker::runAll();