pidFile

Description:

static string Worker::$pidFile

It is recommended not to set this property unless necessary.

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

This setting is useful for monitoring. For example, placing the Workerman pid file in a fixed directory can make it easier for some monitoring software to read the pid file and monitor the Workerman process status.

If not set, Workerman will, by default, generate a pid file at a location parallel to the Workerman directory (note that before workerman 3.2.3, the default location was sys_get_temp_dir()) and, in order to avoid conflicts when starting multiple Workerman instances, the pid file generated by Workerman includes the current Workerman's path.

Note: This property must be set before Worker::runAll(); is called to be effective. 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 the worker
Worker::runAll();