reloadable

Description:

bool Worker::$reloadable

When executing php start.php reload, a reload signal (SIGUSR1) will be sent to all child processes.

Upon receiving the reload signal, the child processes will automatically exit, and the main process will automatically start a new process, which is generally used to update business code.

When the process's $reloadable is set to false, receiving the reload signal will only trigger onWorkerReload and will not restart the current process.

For example, in the Gateway/Worker model, the gateway process is responsible for maintaining client connections, while the worker process handles requests. Setting the reloadable property of the gateway process to false allows for updating business code without disconnecting client connections during a reload.

Example

use Workerman\Worker;
require_once __DIR__ . '/vendor/autoload.php';

$worker = new Worker('websocket://0.0.0.0:8484');
// Set whether this instance will restart upon receiving a reload signal
$worker->reloadable = false;
$worker->onWorkerStart = function($worker)
{
    echo "Worker starting...\n";
};
// Run worker
Worker::runAll();