Ensure all cores are initialised on configure

This commit is contained in:
Sean Harvey 2013-02-13 10:15:14 +13:00
parent deddbe5f15
commit 75938c19a9

View File

@ -87,6 +87,7 @@ class Solr_Configure extends BuildTask {
public function run($request) { public function run($request) {
$service = Solr::service(); $service = Solr::service();
$indexes = Solr::get_indexes();
if (!isset(Solr::$solr_options['indexstore']) || !($index = Solr::$solr_options['indexstore'])) { if (!isset(Solr::$solr_options['indexstore']) || !($index = Solr::$solr_options['indexstore'])) {
user_error('No index configuration for Solr provided', E_USER_ERROR); user_error('No index configuration for Solr provided', E_USER_ERROR);
@ -99,13 +100,15 @@ class Solr_Configure extends BuildTask {
$local = $index['path']; $local = $index['path'];
$remote = isset($index['remotepath']) ? $index['remotepath'] : $local; $remote = isset($index['remotepath']) ? $index['remotepath'] : $local;
foreach (Solr::get_indexes() as $index => $instance) { foreach ($indexes as $index => $instance) {
$sourceDir = $instance->getExtrasPath(); $sourceDir = $instance->getExtrasPath();
$targetDir = "$local/$index/conf"; $targetDir = "$local/$index/conf";
if (!is_dir($targetDir)) { if (!is_dir($targetDir)) {
$worked = @mkdir($targetDir, 0770, true); $worked = @mkdir($targetDir, 0770, true);
if(!$worked) echo sprintf('Failed creating target directory %s, please check permissions', $targetDir); if(!$worked) {
return; echo sprintf('Failed creating target directory %s, please check permissions', $targetDir);
return;
}
} }
file_put_contents("$targetDir/schema.xml", $instance->generateSchema()); file_put_contents("$targetDir/schema.xml", $instance->generateSchema());
@ -152,18 +155,22 @@ class Solr_Configure extends BuildTask {
user_error('Unknown Solr index mode '.$index['mode'], E_USER_ERROR); user_error('Unknown Solr index mode '.$index['mode'], E_USER_ERROR);
} }
if ($service->coreIsActive($index)) { foreach ($indexes as $index => $instance) {
echo "Reloading configuration..."; $indexName = $instance->getName();
$service->coreReload($index);
echo "done\n"; if ($service->coreIsActive($index)) {
} else { echo "Reloading configuration...";
echo "Creating configuration..."; $service->coreReload($index);
$instanceDir = $indexName; echo "done\n";
if ($remote) { } else {
$instanceDir = "$remote/$instanceDir"; echo "Creating configuration...";
$instanceDir = $indexName;
if ($remote) {
$instanceDir = "$remote/$instanceDir";
}
$service->coreCreate($indexName, $instanceDir);
echo "done\n";
} }
$service->coreCreate($indexName, $instanceDir);
echo "done\n";
} }
} }
} }