name

说明:

  1. string Worker::$name

设置当前Worker实例的名称,方便运行status命令时识别进程。不设置时默认为none。

范例

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