OpenSwoole\Server->on('ManagerStart', fn)

Latest version: pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5

Declaration

<?php OpenSwoole\Server->on('ManagerStart', Callable $callback)

Parameters

event

The event callback name.

callback

Callable event function.

Return

success

If success, it returns true, otherwise it returns false.

Description

Execute the callback function when the Manager Process in the Server is started.

The callback function registered for the event ManagerStart is executed in the manager process.

You can alter the name of this process within the callback function and you may use the server sendMessage function to communicate with other worker processes.

At this stage when this callback is executed, all worker and task worker processes have been started but the status of the Master process is still unknown because both the Master and Manager threads are executed concurrently, so either one could complete at the same time.

If running a server using OpenSwoole\Server::SIMPLE_MODE mode and if worker_num, max_request and task_worker_num configuration parameters have been set, OpenSwoole will create the manager processes to act as worker processes, which in return will trigger the ManagerStart and ManagerStop server events, it is more recommended to use OpenSwoole\Server::POOL_MODE mode.

Example

<?php
$server->on('ManagerStart', function(OpenSwoole\Server $server)
{
  // ...
});
Last updated on September 20, 2022