Пример #1
0
#!/usr/bin/php -Cq
<?php 
require_once dirname(dirname(__FILE__)) . '/lib/init-cmd.php';
ini_set('memory_limit', '800M');
$aCMDOptions = array("Create and setup nominatim search system", array('help', 'h', 0, 1, 0, 0, false, 'Show Help'), array('quiet', 'q', 0, 1, 0, 0, 'bool', 'Quiet output'), array('verbose', 'v', 0, 1, 0, 0, 'bool', 'Verbose output'), array('osm-file', '', 0, 1, 1, 1, 'realpath', 'File to import'), array('threads', '', 0, 1, 1, 1, 'int', 'Number of threads (where possible)'), array('all', '', 0, 1, 0, 0, 'bool', 'Do the complete process'), array('create-db', '', 0, 1, 0, 0, 'bool', 'Create nominatim db'), array('setup-db', '', 0, 1, 0, 0, 'bool', 'Build a blank nominatim db'), array('import-data', '', 0, 1, 0, 0, 'bool', 'Import a osm file'), array('create-functions', '', 0, 1, 0, 0, 'bool', 'Create functions'), array('create-minimal-tables', '', 0, 1, 0, 0, 'bool', 'Create minimal main tables'), array('create-tables', '', 0, 1, 0, 0, 'bool', 'Create main tables'), array('create-partitions', '', 0, 1, 0, 0, 'bool', 'Create required partition tables and triggers'), array('load-data', '', 0, 1, 0, 0, 'bool', 'Copy data to live tables from import table'), array('import-tiger-data', '', 0, 1, 0, 0, 'bool', 'Import tiger data (not included in \'all\')'), array('calculate-postcodes', '', 0, 1, 0, 0, 'bool', 'Calculate postcode centroids'), array('create-roads', '', 0, 1, 0, 0, 'bool', 'Calculate postcode centroids'), array('osmosis-init', '', 0, 1, 0, 0, 'bool', 'Generate default osmosis configuration'), array('osmosis-init-date', '', 0, 1, 1, 1, 'string', 'Generate default osmosis configuration'), array('index', '', 0, 1, 0, 0, 'bool', 'Index the data'), array('index-output', '', 0, 1, 1, 1, 'string', 'File to dump index information to'), array('create-search-indices', '', 0, 1, 0, 0, 'bool', 'Create additional indices required for search and update'), array('create-website', '', 0, 1, 1, 1, 'realpath', 'Create symlinks to setup web directory'));
getCmdOpt($_SERVER['argv'], $aCMDOptions, $aCMDResult, true, true);
$bDidSomething = false;
// This is a pretty hard core defult - the number of processors in the box - 1
$iInstances = isset($aCMDResult['threads']) ? $aCMDResult['threads'] : getProcessorCount() - 1;
if ($iInstances < 1) {
    $iInstances = 1;
    echo "WARNING: resetting threads to {$iInstances}\n";
}
if ($iInstances > getProcessorCount()) {
    $iInstances = getProcessorCount();
    echo "WARNING: resetting threads to {$iInstances}\n";
}
if (isset($aCMDResult['osm-file']) && !isset($aCMDResult['osmosis-init-date'])) {
    $sBaseFile = basename($aCMDResult['osm-file']);
    if (preg_match('#^planet-([0-9]{2})([0-9]{2})([0-9]{2})[.]#', $sBaseFile, $aMatch)) {
        $iTime = mktime(0, 0, 0, $aMatch[2], $aMatch[3], '20' . $aMatch[1]);
        $iTime -= 60 * 60 * 24;
        $aCMDResult['osmosis-init-date'] = date('Y-m-d', $iTime) . 'T22:00:00Z';
    }
}
$aDSNInfo = DB::parseDSN(CONST_Database_DSN);
if (!isset($aDSNInfo['port']) || !$aDSNInfo['port']) {
    $aDSNInfo['port'] = 5432;
}
if ($aCMDResult['create-db'] || $aCMDResult['all']) {
    echo "Create DB\n";
Пример #2
0
    }
}
if (have_option('i')) {
    $id = get_option_value('i');
} else {
    if (have_option('--id')) {
        $id = get_option_value('--id');
    } else {
        if (count($args) > 0) {
            $id = $args[0];
        } else {
            $id = null;
        }
    }
}
if (have_option('t')) {
    $threads = intval(get_option_value('t'));
} else {
    if (have_option('--threads')) {
        $threads = intval(get_option_value('--threads'));
    } else {
        $threads = 0;
    }
}
if (!$threads) {
    $threads = getProcessorCount();
}
$daemonize = !(have_option('f') || have_option('--foreground'));
$all = have_option('a') || have_option('--all');
$daemon = new QueueDaemon($id, $daemonize, $threads, $all);
$daemon->runOnce();