more format changes for Mr. Travis

This commit is contained in:
ThomasBarris
2018-08-31 22:01:53 +02:00
parent 42e79bfab9
commit aa6ac5a751

View File

@@ -23,6 +23,7 @@ class SetupFunctions
? $aCMDResult['threads'] ? $aCMDResult['threads']
: (min(16, getProcessorCount()) - 1); : (min(16, getProcessorCount()) - 1);
if ($this->iInstances < 1) { if ($this->iInstances < 1) {
$this->iInstances = 1; $this->iInstances = 1;
warn('resetting threads to '.$this->iInstances); warn('resetting threads to '.$this->iInstances);
@@ -40,9 +41,7 @@ class SetupFunctions
// prepares DB for import or update, sets the Data Source Name // prepares DB for import or update, sets the Data Source Name
$this->aDSNInfo = \DB::parseDSN(CONST_Database_DSN); $this->aDSNInfo = \DB::parseDSN(CONST_Database_DSN);
if (!isset($this->aDSNInfo['port']) || !$this->aDSNInfo['port']) { if (!isset($this->aDSNInfo['port']) || !$this->aDSNInfo['port']) $this->aDSNInfo['port'] = 5432;
$this->aDSNInfo['port'] = 5432;
}
// setting member variables based on command line options stored in $aCMDResult // setting member variables based on command line options stored in $aCMDResult
$this->sVerbose = $aCMDResult['verbose']; $this->sVerbose = $aCMDResult['verbose'];
@@ -75,10 +74,7 @@ class SetupFunctions
} }
$result = runWithEnv($sCreateDBCmd, $aProcEnv); $result = runWithEnv($sCreateDBCmd, $aProcEnv);
if ($result != 0) { if ($result != 0) fail('Error executing external command: '.$sCreateDBCmd);
fail('Error executing external command: ' . $sCreateDBCmd);
}
} }
public function setupDB() public function setupDB()
@@ -106,6 +102,7 @@ class SetupFunctions
warn('Postgresql is too old. extratags and namedetails API not available.'); warn('Postgresql is too old. extratags and namedetails API not available.');
} }
$fPostgisVersion = getPostgisVersion($this->oDB); $fPostgisVersion = getPostgisVersion($this->oDB);
echo 'Postgis version found: '.$fPostgisVersion."\n"; echo 'Postgis version found: '.$fPostgisVersion."\n";
@@ -135,6 +132,7 @@ class SetupFunctions
$this->pgsqlRunScriptFile(CONST_BasePath.'/data/country_osm_grid.sql.gz'); $this->pgsqlRunScriptFile(CONST_BasePath.'/data/country_osm_grid.sql.gz');
$this->pgsqlRunScriptFile(CONST_BasePath.'/data/gb_postcode_table.sql'); $this->pgsqlRunScriptFile(CONST_BasePath.'/data/gb_postcode_table.sql');
if (file_exists(CONST_BasePath.'/data/gb_postcode_data.sql.gz')) { if (file_exists(CONST_BasePath.'/data/gb_postcode_data.sql.gz')) {
$this->pgsqlRunScriptFile(CONST_BasePath.'/data/gb_postcode_data.sql.gz'); $this->pgsqlRunScriptFile(CONST_BasePath.'/data/gb_postcode_data.sql.gz');
} else { } else {
@@ -168,26 +166,20 @@ class SetupFunctions
fail("osm2pgsql not found in '$osm2pgsql'"); fail("osm2pgsql not found in '$osm2pgsql'");
} }
if (!is_null(CONST_Osm2pgsql_Flatnode_File) && CONST_Osm2pgsql_Flatnode_File) { if (!is_null(CONST_Osm2pgsql_Flatnode_File) && CONST_Osm2pgsql_Flatnode_File) {
$osm2pgsql .= ' --flat-nodes '.CONST_Osm2pgsql_Flatnode_File; $osm2pgsql .= ' --flat-nodes '.CONST_Osm2pgsql_Flatnode_File;
} }
if (CONST_Tablespace_Osm2pgsql_Data) { if (CONST_Tablespace_Osm2pgsql_Data)
$osm2pgsql .= ' --tablespace-slim-data '.CONST_Tablespace_Osm2pgsql_Data; $osm2pgsql .= ' --tablespace-slim-data '.CONST_Tablespace_Osm2pgsql_Data;
} if (CONST_Tablespace_Osm2pgsql_Index)
if (CONST_Tablespace_Osm2pgsql_Index) {
$osm2pgsql .= ' --tablespace-slim-index '.CONST_Tablespace_Osm2pgsql_Index; $osm2pgsql .= ' --tablespace-slim-index '.CONST_Tablespace_Osm2pgsql_Index;
} if (CONST_Tablespace_Place_Data)
if (CONST_Tablespace_Place_Data) {
$osm2pgsql .= ' --tablespace-main-data '.CONST_Tablespace_Place_Data; $osm2pgsql .= ' --tablespace-main-data '.CONST_Tablespace_Place_Data;
} if (CONST_Tablespace_Place_Index)
if (CONST_Tablespace_Place_Index) {
$osm2pgsql .= ' --tablespace-main-index '.CONST_Tablespace_Place_Index; $osm2pgsql .= ' --tablespace-main-index '.CONST_Tablespace_Place_Index;
}
$osm2pgsql .= ' -lsc -O gazetteer --hstore --number-processes 1'; $osm2pgsql .= ' -lsc -O gazetteer --hstore --number-processes 1';
$osm2pgsql .= ' -C '.$this->iCacheMemory; $osm2pgsql .= ' -C '.$this->iCacheMemory;
$osm2pgsql .= ' -P '.$this->aDSNInfo['port']; $osm2pgsql .= ' -P '.$this->aDSNInfo['port'];
@@ -203,10 +195,7 @@ class SetupFunctions
} }
$osm2pgsql .= ' -d '.$this->aDSNInfo['database'].' '.$sOSMFile; $osm2pgsql .= ' -d '.$this->aDSNInfo['database'].' '.$sOSMFile;
runWithEnv($osm2pgsql, $aProcEnv); runWithEnv($osm2pgsql, $aProcEnv);
if ($this->oDB == null) { if ($this->oDB == null) $this->oDB =& getDB();
$this->oDB = &getDB();
}
if (!$this->sIgnoreErrors && !chksql($this->oDB->getRow('select * from place limit 1'))) { if (!$this->sIgnoreErrors && !chksql($this->oDB->getRow('select * from place limit 1'))) {
fail('No Data'); fail('No Data');
} }
@@ -334,72 +323,34 @@ class SetupFunctions
{ {
info('Drop old Data'); info('Drop old Data');
if ($this->oDB == null) { if ($this->oDB == null) $this->oDB =& getDB();
$this->oDB = &getDB();
}
if (!pg_query($this->oDB->connection, 'TRUNCATE word')) {
fail(pg_last_error($this->oDB->connection));
}
if (!pg_query($this->oDB->connection, 'TRUNCATE word')) fail(pg_last_error($this->oDB->connection));
echo '.'; echo '.';
if (!pg_query($this->oDB->connection, 'TRUNCATE placex')) { if (!pg_query($this->oDB->connection, 'TRUNCATE placex')) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
echo '.'; echo '.';
if (!pg_query($this->oDB->connection, 'TRUNCATE location_property_osmline')) { if (!pg_query($this->oDB->connection, 'TRUNCATE location_property_osmline')) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
echo '.'; echo '.';
if (!pg_query($this->oDB->connection, 'TRUNCATE place_addressline')) { if (!pg_query($this->oDB->connection, 'TRUNCATE place_addressline')) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
echo '.'; echo '.';
if (!pg_query($this->oDB->connection, 'TRUNCATE place_boundingbox')) { if (!pg_query($this->oDB->connection, 'TRUNCATE place_boundingbox')) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
echo '.'; echo '.';
if (!pg_query($this->oDB->connection, 'TRUNCATE location_area')) { if (!pg_query($this->oDB->connection, 'TRUNCATE location_area')) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
echo '.'; echo '.';
if (!pg_query($this->oDB->connection, 'TRUNCATE search_name')) { if (!pg_query($this->oDB->connection, 'TRUNCATE search_name')) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
echo '.'; echo '.';
if (!pg_query($this->oDB->connection, 'TRUNCATE search_name_blank')) { if (!pg_query($this->oDB->connection, 'TRUNCATE search_name_blank')) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
echo '.'; echo '.';
if (!pg_query($this->oDB->connection, 'DROP SEQUENCE seq_place')) { if (!pg_query($this->oDB->connection, 'DROP SEQUENCE seq_place')) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
echo '.'; echo '.';
if (!pg_query($this->oDB->connection, 'CREATE SEQUENCE seq_place start 100000')) { if (!pg_query($this->oDB->connection, 'CREATE SEQUENCE seq_place start 100000')) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
echo '.'; echo '.';
$sSQL = 'select distinct partition from country_name'; $sSQL = 'select distinct partition from country_name';
$aPartitions = chksql($this->oDB->getCol($sSQL)); $aPartitions = chksql($this->oDB->getCol($sSQL));
if (!$this->bNoPartitions) { if (!$this->bNoPartitions) $aPartitions[] = 0;
$aPartitions[] = 0;
}
foreach ($aPartitions as $sPartition) { foreach ($aPartitions as $sPartition) {
if (!pg_query($this->oDB->connection, 'TRUNCATE location_road_' . $sPartition)) { if (!pg_query($this->oDB->connection, 'TRUNCATE location_road_'.$sPartition)) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
echo '.'; echo '.';
} }
@@ -427,10 +378,7 @@ class SetupFunctions
$sSQL .= " and not (class='place' and type='houses' and osm_type='W'"; $sSQL .= " and not (class='place' and type='houses' and osm_type='W'";
$sSQL .= " and ST_GeometryType(geometry) = 'ST_LineString')"; $sSQL .= " and ST_GeometryType(geometry) = 'ST_LineString')";
$sSQL .= ' and ST_IsValid(geometry)'; $sSQL .= ' and ST_IsValid(geometry)';
if ($this->sVerbose) { if ($this->sVerbose) echo "$sSQL\n";
echo "$sSQL\n";
}
if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) { if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) {
fail(pg_last_error($aDBInstances[$i]->connection)); fail(pg_last_error($aDBInstances[$i]->connection));
} }
@@ -442,10 +390,7 @@ class SetupFunctions
$sSQL .= ' (osm_id, address, linegeo)'; $sSQL .= ' (osm_id, address, linegeo)';
$sSQL .= ' SELECT osm_id, address, geometry from place where '; $sSQL .= ' SELECT osm_id, address, geometry from place where ';
$sSQL .= "class='place' and type='houses' and osm_type='W' and ST_GeometryType(geometry) = 'ST_LineString'"; $sSQL .= "class='place' and type='houses' and osm_type='W' and ST_GeometryType(geometry) = 'ST_LineString'";
if ($this->sVerbose) { if ($this->sVerbose) echo "$sSQL\n";
echo "$sSQL\n";
}
if (!pg_send_query($aDBInstances[$iLoadThreads]->connection, $sSQL)) { if (!pg_send_query($aDBInstances[$iLoadThreads]->connection, $sSQL)) {
fail(pg_last_error($aDBInstances[$iLoadThreads]->connection)); fail(pg_last_error($aDBInstances[$iLoadThreads]->connection));
} }
@@ -516,14 +461,8 @@ class SetupFunctions
if (!pg_connection_busy($aDBInstances[$i]->connection)) { if (!pg_connection_busy($aDBInstances[$i]->connection)) {
while (pg_get_result($aDBInstances[$i]->connection)); while (pg_get_result($aDBInstances[$i]->connection));
$sSQL = fgets($hFile, 100000); $sSQL = fgets($hFile, 100000);
if (!$sSQL) { if (!$sSQL) break 2;
break 2; if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) fail(pg_last_error($this->oDB->connection));
}
if (!pg_send_query($aDBInstances[$i]->connection, $sSQL)) {
fail(pg_last_error($this->oDB->connection));
}
$iLines++; $iLines++;
if ($iLines == 1000) { if ($iLines == 1000) {
echo '.'; echo '.';
@@ -539,10 +478,7 @@ class SetupFunctions
while ($bAnyBusy) { while ($bAnyBusy) {
$bAnyBusy = false; $bAnyBusy = false;
for ($i = 0; $i < $this->iInstances; $i++) { for ($i = 0; $i < $this->iInstances; $i++) {
if (pg_connection_busy($aDBInstances[$i]->connection)) { if (pg_connection_busy($aDBInstances[$i]->connection)) $bAnyBusy = true;
$bAnyBusy = true;
}
} }
usleep(10); usleep(10);
} }
@@ -568,14 +504,12 @@ class SetupFunctions
public function calculatePostcodes($bCMDResultAll) public function calculatePostcodes($bCMDResultAll)
{ {
info('Calculate Postcodes'); info('Calculate Postcodes');
if ($this->oDB == null) { if ($this->oDB == null) $this->oDB =& getDB();
$this->oDB = &getDB();
}
if (!pg_query($this->oDB->connection, 'TRUNCATE location_postcode')) { if (!pg_query($this->oDB->connection, 'TRUNCATE location_postcode')) {
fail(pg_last_error($this->oDB->connection)); fail(pg_last_error($this->oDB->connection));
} }
$sSQL = 'INSERT INTO location_postcode'; $sSQL = 'INSERT INTO location_postcode';
$sSQL .= ' (place_id, indexed_status, country_code, postcode, geometry) '; $sSQL .= ' (place_id, indexed_status, country_code, postcode, geometry) ';
$sSQL .= "SELECT nextval('seq_place'), 1, country_code,"; $sSQL .= "SELECT nextval('seq_place'), 1, country_code,";
@@ -599,10 +533,7 @@ class SetupFunctions
$sSQL .= ' FROM us_postcode WHERE postcode NOT IN'; $sSQL .= ' FROM us_postcode WHERE postcode NOT IN';
$sSQL .= ' (SELECT postcode FROM location_postcode'; $sSQL .= ' (SELECT postcode FROM location_postcode';
$sSQL .= " WHERE country_code = 'us')"; $sSQL .= " WHERE country_code = 'us')";
if (!pg_query($this->oDB->connection, $sSQL)) { if (!pg_query($this->oDB->connection, $sSQL)) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
} }
// add missing postcodes for GB (if available) // add missing postcodes for GB (if available)
@@ -612,9 +543,7 @@ class SetupFunctions
$sSQL .= ' FROM gb_postcode WHERE postcode NOT IN'; $sSQL .= ' FROM gb_postcode WHERE postcode NOT IN';
$sSQL .= ' (SELECT postcode FROM location_postcode'; $sSQL .= ' (SELECT postcode FROM location_postcode';
$sSQL .= " WHERE country_code = 'gb')"; $sSQL .= " WHERE country_code = 'gb')";
if (!pg_query($this->oDB->connection, $sSQL)) { if (!pg_query($this->oDB->connection, $sSQL)) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
if (!$bCMDResultAll) { if (!$bCMDResultAll) {
$sSQL = "DELETE FROM word WHERE class='place' and type='postcode'"; $sSQL = "DELETE FROM word WHERE class='place' and type='postcode'";
@@ -652,34 +581,22 @@ class SetupFunctions
if ($iStatus != 0) { if ($iStatus != 0) {
fail('error status ' . $iStatus . ' running nominatim!'); fail('error status ' . $iStatus . ' running nominatim!');
} }
if (!$bIndexNoanalyse) { if (!$bIndexNoanalyse) $this->pgsqlRunScript('ANALYSE');
$this->pgsqlRunScript('ANALYSE');
}
info('Index ranks 5 - 25'); info('Index ranks 5 - 25');
$iStatus = runWithEnv($sBaseCmd.' -r 5 -R 25', $aProcEnv); $iStatus = runWithEnv($sBaseCmd.' -r 5 -R 25', $aProcEnv);
if ($iStatus != 0) { if ($iStatus != 0) {
fail('error status ' . $iStatus . ' running nominatim!'); fail('error status ' . $iStatus . ' running nominatim!');
} }
if (!$bIndexNoanalyse) { if (!$bIndexNoanalyse) $this->pgsqlRunScript('ANALYSE');
$this->pgsqlRunScript('ANALYSE');
}
info('Index ranks 26 - 30'); info('Index ranks 26 - 30');
$iStatus = runWithEnv($sBaseCmd.' -r 26', $aProcEnv); $iStatus = runWithEnv($sBaseCmd.' -r 26', $aProcEnv);
if ($iStatus != 0) { if ($iStatus != 0) {
fail('error status ' . $iStatus . ' running nominatim!'); fail('error status ' . $iStatus . ' running nominatim!');
} }
info('Index postcodes'); info('Index postcodes');
if ($this->oDB == null) { if ($this->oDB == null) $this->oDB =& getDB();
$this->oDB = &getDB();
}
$sSQL = 'UPDATE location_postcode SET indexed_status = 0'; $sSQL = 'UPDATE location_postcode SET indexed_status = 0';
if (!pg_query($this->oDB->connection, $sSQL)) { if (!pg_query($this->oDB->connection, $sSQL)) fail(pg_last_error($this->oDB->connection));
fail(pg_last_error($this->oDB->connection));
}
} }
public function createSearchIndices() public function createSearchIndices()
@@ -756,13 +673,10 @@ class SetupFunctions
'new_query_log', 'new_query_log',
'spatial_ref_sys', 'spatial_ref_sys',
'country_name', 'country_name',
'place_classtype_*', 'place_classtype_*'
); );
if ($this->oDB = null) { if ($this->oDB = null) $this->oDB =& getDB();
$this->oDB = &getDB();
}
$aDropTables = array(); $aDropTables = array();
$aHaveTables = chksql($this->oDB->getCol("SELECT tablename FROM pg_tables WHERE schemaname='public'")); $aHaveTables = chksql($this->oDB->getCol("SELECT tablename FROM pg_tables WHERE schemaname='public'"));
@@ -774,36 +688,24 @@ class SetupFunctions
break; break;
} }
} }
if (!$bFound) { if (!$bFound) array_push($aDropTables, $sTable);
array_push($aDropTables, $sTable);
}
} }
foreach ($aDropTables as $sDrop) { foreach ($aDropTables as $sDrop) {
if ($this->sVerbose) { if ($this->sVerbose) echo "dropping table $sDrop\n";
echo "dropping table $sDrop\n";
}
@pg_query($this->oDB->connection, "DROP TABLE $sDrop CASCADE"); @pg_query($this->oDB->connection, "DROP TABLE $sDrop CASCADE");
// ignore warnings/errors as they might be caused by a table having // ignore warnings/errors as they might be caused by a table having
// been deleted already by CASCADE // been deleted already by CASCADE
} }
if (!is_null(CONST_Osm2pgsql_Flatnode_File) && CONST_Osm2pgsql_Flatnode_File) { if (!is_null(CONST_Osm2pgsql_Flatnode_File) && CONST_Osm2pgsql_Flatnode_File) {
if ($sVerbose) { if ($sVerbose) echo 'deleting '.CONST_Osm2pgsql_Flatnode_File."\n";
echo 'deleting ' . CONST_Osm2pgsql_Flatnode_File . "\n";
}
unlink(CONST_Osm2pgsql_Flatnode_File); unlink(CONST_Osm2pgsql_Flatnode_File);
} }
} }
private function pgsqlRunDropAndRestore($sDumpFile) private function pgsqlRunDropAndRestore($sDumpFile)
{ {
if (!isset($this->aDSNInfo['port']) || !$this->aDSNInfo['port']) { if (!isset($this->aDSNInfo['port']) || !$this->aDSNInfo['port']) $this->aDSNInfo['port'] = 5432;
$this->aDSNInfo['port'] = 5432;
}
$sCMD = 'pg_restore -p '.$this->aDSNInfo['port'].' -d '.$this->aDSNInfo['database'].' -Fc --clean '.$sDumpFile; $sCMD = 'pg_restore -p '.$this->aDSNInfo['port'].' -d '.$this->aDSNInfo['database'].' -Fc --clean '.$sDumpFile;
if (isset($this->aDSNInfo['hostspec']) && $this->aDSNInfo['hostspec']) { if (isset($this->aDSNInfo['hostspec']) && $this->aDSNInfo['hostspec']) {
$sCMD .= ' -h ' . $this->aDSNInfo['hostspec']; $sCMD .= ' -h ' . $this->aDSNInfo['hostspec'];
@@ -852,15 +754,11 @@ class SetupFunctions
private function pgsqlRunPartitionScript($sTemplate) private function pgsqlRunPartitionScript($sTemplate)
{ {
if ($this->oDB == null) { if ($this->oDB == null) $this->oDB =& getDB();
$this->oDB = &getDB();
}
$sSQL = 'select distinct partition from country_name'; $sSQL = 'select distinct partition from country_name';
$aPartitions = chksql($this->oDB->getCol($sSQL)); $aPartitions = chksql($this->oDB->getCol($sSQL));
if (!$this->bNoPartitions) { if (!$this->bNoPartitions) $aPartitions[] = 0;
$aPartitions[] = 0;
}
preg_match_all('#^-- start(.*?)^-- end#ms', $sTemplate, $aMatches, PREG_SET_ORDER); preg_match_all('#^-- start(.*?)^-- end#ms', $sTemplate, $aMatches, PREG_SET_ORDER);
foreach ($aMatches as $aMatch) { foreach ($aMatches as $aMatch) {
@@ -876,9 +774,7 @@ class SetupFunctions
private function pgsqlRunScriptFile($sFilename) private function pgsqlRunScriptFile($sFilename)
{ {
if (!file_exists($sFilename)) { if (!file_exists($sFilename)) fail('unable to find '.$sFilename);
fail('unable to find ' . $sFilename);
}
$sCMD = 'psql -p '.$this->aDSNInfo['port'].' -d '.$this->aDSNInfo['database']; $sCMD = 'psql -p '.$this->aDSNInfo['port'].' -d '.$this->aDSNInfo['database'];
if (!$this->sVerbose) { if (!$this->sVerbose) {
@@ -899,13 +795,10 @@ class SetupFunctions
$aDescriptors = array( $aDescriptors = array(
0 => array('pipe', 'r'), 0 => array('pipe', 'r'),
1 => array('pipe', 'w'), 1 => array('pipe', 'w'),
2 => array('file', '/dev/null', 'a'), 2 => array('file', '/dev/null', 'a')
); );
$hGzipProcess = proc_open('zcat '.$sFilename, $aDescriptors, $ahGzipPipes); $hGzipProcess = proc_open('zcat '.$sFilename, $aDescriptors, $ahGzipPipes);
if (!is_resource($hGzipProcess)) { if (!is_resource($hGzipProcess)) fail('unable to start zcat');
fail('unable to start zcat');
}
$aReadPipe = $ahGzipPipes[1]; $aReadPipe = $ahGzipPipes[1];
fclose($ahGzipPipes[0]); fclose($ahGzipPipes[0]);
} else { } else {
@@ -915,14 +808,11 @@ class SetupFunctions
$aDescriptors = array( $aDescriptors = array(
0 => $aReadPipe, 0 => $aReadPipe,
1 => array('pipe', 'w'), 1 => array('pipe', 'w'),
2 => array('file', '/dev/null', 'a'), 2 => array('file', '/dev/null', 'a')
); );
$ahPipes = null; $ahPipes = null;
$hProcess = proc_open($sCMD, $aDescriptors, $ahPipes, null, $aProcEnv); $hProcess = proc_open($sCMD, $aDescriptors, $ahPipes, null, $aProcEnv);
if (!is_resource($hProcess)) { if (!is_resource($hProcess)) fail('unable to start pgsql');
fail('unable to start pgsql');
}
// TODO: error checking // TODO: error checking
while (!feof($ahPipes[1])) { while (!feof($ahPipes[1])) {
echo fread($ahPipes[1], 4096); echo fread($ahPipes[1], 4096);