Update URI check to include CLI request detection.

The code now checks if the request URI is '/metrics' or if the PHP script is running from the command line interface (CLI). This change allows for proper handling of CLI requests in addition to web requests.
This commit is contained in:
Jeroen De Meerleer 2024-06-03 19:48:39 +02:00
parent 7c61ead8ac
commit 66933d7d19
Signed by: JeroenED
GPG Key ID: 28CCCB8F62BFADD6

View File

@ -2,7 +2,7 @@
require 'vendor/autoload.php'; require 'vendor/autoload.php';
require 'config.php'; require 'config.php';
if($_SERVER["REQUEST_URI"] == '/metrics') { if($_SERVER["REQUEST_URI"] == '/metrics' || php_sapi_name() == 'cli') {
foreach ($config as $key => &$c) { foreach ($config as $key => &$c) {
if(isset($c['command'])) { if(isset($c['command'])) {
$output=null; $output=null;