[FIX] simulate wrapper: PHP_BINARY→php-cli corretto (FPM≠CLI)
This commit is contained in:
parent
49c62ab811
commit
2e83e66932
@ -52,7 +52,14 @@ if ($simParam === 'sim06') {
|
|||||||
// ── Avvia subprocess (pattern lg231 runCommand) ───────────────────────────────
|
// ── Avvia subprocess (pattern lg231 runCommand) ───────────────────────────────
|
||||||
$descriptors = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']];
|
$descriptors = [0 => ['pipe', 'r'], 1 => ['pipe', 'w'], 2 => ['pipe', 'w']];
|
||||||
$cwd = dirname($scriptPath);
|
$cwd = dirname($scriptPath);
|
||||||
$cmd = PHP_BINARY . ' ' . escapeshellarg($scriptPath);
|
// PHP_BINARY in PHP-FPM punta a php-fpm, non al CLI → cerca il binario CLI corretto
|
||||||
|
$phpBin = PHP_BINARY;
|
||||||
|
if (str_contains($phpBin, 'fpm') || !is_executable($phpBin)) {
|
||||||
|
foreach (['/usr/bin/php' . PHP_MAJOR_VERSION . '.' . PHP_MINOR_VERSION, '/usr/bin/php', 'php'] as $try) {
|
||||||
|
if (is_executable($try) || shell_exec("which $try 2>/dev/null")) { $phpBin = $try; break; }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
$cmd = $phpBin . ' ' . escapeshellarg($scriptPath);
|
||||||
$proc = proc_open($cmd, $descriptors, $pipes, $cwd, $env);
|
$proc = proc_open($cmd, $descriptors, $pipes, $cwd, $env);
|
||||||
|
|
||||||
if (!is_resource($proc)) {
|
if (!is_resource($proc)) {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user