Swoole Server getWorkerStatus()

Declaration

<?php
Swoole\Server->getWorkerStatus(int $workerId): int|bool

Parameters

none

Return

workerStatus

Return the worker process status value as an integer. This value indicates the workers state.

Description

By passing in the worker process ID you can retrieve the worker status as an integer.

Worker Status Values

  • SWOOLE_WORKER_BUSY (1): The worker process is busy.
  • SWOOLE_WORKER_IDLE (2): The worker process is idle.
  • SWOOLE_WORKER_EXIT (3): When you have the Swoole server set to reload on code changes, there may be two worker processes with the same ID, an old one and a new one, the old worker process waiting to finish and be replaced by the new one will have the exit status.

Available since > v4.5.0