pidFile

Description:

static string Worker::$pidFile

It is recommended not to set this attribute unless necessary.

This attribute is a global static property used to set the pid file path for Workerman processes.

This setting is particularly useful for monitoring purposes; for example, placing the Workerman's pid file in a fixed directory allows some monitoring software to easily read the pid file, thereby monitoring the status of the Workerman process.

If not set, Workerman will automatically generate a pid file in a location parallel to the Workerman directory (note that in versions before workerman3.2.3, the default was in sys_get_temp_dir()), and to avoid pid conflicts caused by starting multiple Workerman instances, the generated pid file includes the current Workerman's path.

Note: This attribute must be set before Worker::runAll(); is executed to take effect. This feature is not supported on Windows systems.

Example

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

Worker::$pidFile = '/var/run/workerman.pid';

$worker = new Worker('text://0.0.0.0:8484');
$worker->onWorkerStart = function($worker)
{
    echo "Worker start";
};
// Run worker
Worker::runAll();