2018-01-26 14:14:23 +01:00
|
|
|
#!/usr/bin/env php
|
2016-04-06 21:27:47 +02:00
|
|
|
<?php
|
|
|
|
/**
|
|
|
|
* API - run Timed Asynchron Services for all EGroupware domain/instances
|
|
|
|
*
|
2020-11-19 11:22:16 +01:00
|
|
|
* 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.
|
|
|
|
*
|
2016-04-06 21:27:47 +02:00
|
|
|
* @link http://www.egroupware.org
|
2020-11-19 11:22:16 +01:00
|
|
|
* @author Ralf Becker
|
2016-04-06 21:27:47 +02:00
|
|
|
* @license http://opensource.org/licenses/gpl-license.php GPL - GNU General Public License
|
|
|
|
* @package api
|
|
|
|
* @access public
|
|
|
|
*/
|
|
|
|
|
|
|
|
$path_to_egroupware = realpath(__DIR__.'/..'); // need to be adapted if this script is moved somewhere else
|
|
|
|
|
2020-11-19 11:22:16 +01:00
|
|
|
// 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');
|
|
|
|
}
|
|
|
|
|
2016-04-06 21:27:47 +02:00
|
|
|
foreach(file($path_to_egroupware. '/header.inc.php') as $line)
|
|
|
|
{
|
|
|
|
if(preg_match("/GLOBALS\['egw_domain']\['(.*)']/", $line, $matches))
|
|
|
|
{
|
2020-11-19 11:22:16 +01:00
|
|
|
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]);
|
|
|
|
}
|
|
|
|
}
|
2016-04-06 21:27:47 +02:00
|
|
|
}
|
|
|
|
}
|