mirror of
https://github.com/EGroupware/egroupware.git
synced 2024-11-21 15:33:23 +01:00
* API: call async-services via HTTP to fix diverse caching problems
This commit is contained in:
parent
20a7cd6c76
commit
dabf3ac3a4
@ -3,8 +3,11 @@
|
||||
/**
|
||||
* API - run Timed Asynchron Services for all EGroupware domain/instances
|
||||
*
|
||||
* To work around caching-problems (PHP cli uses different shared memory then FPM) we
|
||||
* try first to call asyncservices.php via HTTP, before falling back to the old PHP cli call.
|
||||
*
|
||||
* @link http://www.egroupware.org
|
||||
* @author Lars Kneschke
|
||||
* @author Ralf Becker
|
||||
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
||||
* @package api
|
||||
* @access public
|
||||
@ -12,11 +15,29 @@
|
||||
|
||||
$path_to_egroupware = realpath(__DIR__.'/..'); // need to be adapted if this script is moved somewhere else
|
||||
|
||||
// we try http://nginx/ (Docker), http://localhost/ or cli
|
||||
$methods = ['http://localhost/egroupware/api/asyncservices.php','cli'];
|
||||
if (gethostbyname('nginx.') !== 'nginx.')
|
||||
{
|
||||
array_unshift($methods, 'http://nginx/egroupware/api/asyncservices.php');
|
||||
}
|
||||
|
||||
foreach(file($path_to_egroupware. '/header.inc.php') as $line)
|
||||
{
|
||||
if(preg_match("/GLOBALS\['egw_domain']\['(.*)']/", $line, $matches))
|
||||
{
|
||||
// -d memory_limit=-1 --> no memory limit
|
||||
system(PHP_BINARY. ' -q -d memory_limit=-1 '.$path_to_egroupware.'/api/asyncservices.php '. $matches[1]);
|
||||
foreach($methods as $key => $url)
|
||||
{
|
||||
if ($url !== 'cli')
|
||||
{
|
||||
$url .= '?run_by=crontab&domain='.urlencode($matches[1]);
|
||||
if (file_get_contents($url) !== false) break;
|
||||
}
|
||||
else
|
||||
{
|
||||
// -d memory_limit=-1 --> no memory limit
|
||||
system(PHP_BINARY. ' -q -d memory_limit=-1 '.$path_to_egroupware.'/api/asyncservices.php '. $matches[1]);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user