Swoole\Server->on('workererror', fn)

Declaration

<?php
Swoole\Server->on('workererror', callback $callback)

Parameters

event

The event name

callback

callback function

Return

success

if success, it returns TRUE, otherwise it returns FALSE.

Description

Executue the callback function when a Worker Process is stopped caused by Error or Exception.

The callback funciton is executed in the Manager Process.

Callback function

<?php
function (Swoole\Server $server, int $worker_id, int $worker_pid, int $exit_code, int $signal) {

}
  • $worker_id the id number of worker
  • $worker_pid the pid of worker process
  • $exit_code the exit code of worker process
  • $signal the exit signal of worker process

Example