Open DiegoPino opened 1 year ago
There are some documented bugs here regarding this https://bugs.php.net/bug.php?id=73342
Seems like we could do this (like we do on SBR) Because the parent process detaches eventually we could close it... but this needs testing
$command = 'command to execute...';
$pipes = array();
$process = proc_open(
$command,
array(
0 => array('pipe', 'r'),
1 => array('pipe', 'w'),
2 => array('pipe', 'w'),
),
$pipes
);
stream_set_blocking($pipes[1], true);
stream_set_blocking($pipes[2], true);
if (
is_resource($process)
) {
$output = stream_get_contents($pipes[1]);
$error = stream_get_contents($pipes[2]);
fclose($pipes[1]);
fclose($pipes[2]);
proc_close($process);
}
This may be related to ISSUE-75 (issue, pull-request). We found that on large background ocr queues we were getting multiple processes running the same ghostscript and tesseract commands, and this could possibly be the result of \Drupal\strawberry_runners\Plugin\StrawberryRunnersPostProcessorPluginBase::proc_execute
failing to close processes due to having incorrect process ids.
@patdunlavey this is not what I observed today. What I observed is you were running Hydroponics via Drush multiple times and they competing and using all resources. Is this a new issue I did not see?
I didn't notice that this issue was being reported for the strawberryfield module, not strawberry_runners, and that it proposes to solve it using an approach implemented in strawberry_runners. Apologies for the confusion!
Still pending.
What?
@giancarlobi @patdunlavey @aksm this code here:
https://github.com/esmero/strawberryfield/blob/911f8cbbfa6429636846ddc75cd5316103a46cc4/src/StrawberryfieldHydroponicsService.php#L170-L213
Seems to be getting the PID of the
sh
that calls the command itself, but not the child process that is started. When we kill it, we are leaving a Child behind that eventually dies but gives this errorphp-fpm "oops, unknown child exited with 0".
I think we should try with
proc_open
instead ofexec
? Or, save not only the PID of the Parent Process but also of the child one. Then when we need to kill it, we try first aSIGTERM
? If that does not kill both (parent and child) we try with the Child first, then the parent?This is not a very big deal but I would love to see those errors gone, might end generating a slow down eventually (and a lot of php-fpm processes) on heavy load.