retry loop on osmosis

This commit is contained in:
Brian Quinion 2011-04-27 12:14:33 +00:00
parent b3f2bdb822
commit 5f97080c73

View File

@ -1,5 +1,6 @@
#!/usr/bin/php -Cq #!/usr/bin/php -Cq
<?php <?php
require_once(dirname(dirname(__FILE__)).'/lib/init-cmd.php'); require_once(dirname(dirname(__FILE__)).'/lib/init-cmd.php');
ini_set('memory_limit', '800M'); ini_set('memory_limit', '800M');
@ -323,10 +324,12 @@
$fCMDStartTime = time(); $fCMDStartTime = time();
echo $sCMDDownload."\n"; echo $sCMDDownload."\n";
exec($sCMDDownload, $sJunk, $iErrorLevel); exec($sCMDDownload, $sJunk, $iErrorLevel);
if ($iErrorLevel) while ($iErrorLevel == 1)
{ {
echo "Error: $iErrorLevel\n"; echo "Error: $iErrorLevel\n";
exit; sleep(60);
echo 'Re-trying: '.$sCMDDownload."\n";
exec($sCMDDownload, $sJunk, $iErrorLevel);
} }
$iFileSize = filesize($sImportFile); $iFileSize = filesize($sImportFile);
$sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory); $sBatchEnd = getosmosistimestamp($sOsmosisConfigDirectory);
@ -418,7 +421,6 @@
echo "Completed for $sBatchEnd in ".round($fDuration/60,2)."\n"; echo "Completed for $sBatchEnd in ".round($fDuration/60,2)."\n";
if (!$aResult['import-osmosis-all']) exit; if (!$aResult['import-osmosis-all']) exit;
// } // }
echo "Sleeping ".max(0,60-$fDuration)." seconds\n"; echo "Sleeping ".max(0,60-$fDuration)." seconds\n";
sleep(max(0,60-$fDuration)); sleep(max(0,60-$fDuration));
} }
@ -448,7 +450,7 @@
$sImportFile .= ".npi"; $sImportFile .= ".npi";
while(!file_exists($sImportFile) && !file_exists($sImportFile.'.bz2')) while(!file_exists($sImportFile) && !file_exists($sImportFile.'.bz2'))
{ {
echo "sleep\n"; echo "sleep (waiting for $sImportFile)\n";
sleep(10); sleep(10);
} }
if (file_exists($sImportFile.'.bz2')) $sImportFile .= '.bz2'; if (file_exists($sImportFile.'.bz2')) $sImportFile .= '.bz2';