// loop multiple sources
foreach ($sources as $source) {
$this->remote($source['url']);
sleep(10);
}
//
次にリモートxmlを取得し、結果を読み取りますが、最初の大きなxmlを読み取った後、次にプロセスを強制終了します。
public function remote($fileUrl)
{
try {
$http = new Client();
$results = $http->get($fileUrl,[], ['timeout' => 2000]);
$xml = $results->xml; // <----------- 1st success, then kill next loop
//$this->prepare_data($xml);
$http = null;
$results = null;
$xml = null;
} catch (\Exception $e) {
\Cake\Log\Log::error("File does not exists or can't read!", "error");
\Cake\Log\Log::error($e->getMessage(), 'error');
}
return true;
}
この問題は、テストおよびマスターサーバー(platform.sh)、開発者のローカルホストでは問題ありません。
最初のループの後にメモリと空きリソースをクリアする方法は?
おそらくphpのタイムアウト、できます(お勧めしません):
ただし、CakePHPシェルを使用してこのプロセスをバックグラウンドで実行することをお勧めします。https://book.cakephp.org/3.0/en/console-and-shells.html#the-cakephp-consoleを参照してください