Join 4,000+ others and never miss out on new tips, tutorials, and more.
Latest version:
pecl install openswoole-22.1.2 | composer require openswoole/core:22.1.5
<?php OpenSwoole\Server->on('ManagerStart', Callable $callback)
The event callback name.
Callable event function.
If success, it returns true
, otherwise it returns false
.
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.
<?php
$server->on('ManagerStart', function(OpenSwoole\Server $server)
{
// ...
});