mirror of
https://we.phorge.it/source/phorge.git
synced 2024-11-26 08:42:41 +01:00
Make bin/search init
messaging a little more consistent
Summary: Ref T12450. This mostly just smooths out the text a little to improve consistency. Also: - Use `isWritable()`. - Make the "skipping because not writable" message more clear and tailored. - Try not to use the word "index" too much to avoid confusion with `bin/search index` -- instead, talk about "initialize a service". Test Plan: Ran `bin/search init` with a couple of different (writable / not writable) configs, saw slightly clearer messaging. Reviewers: chad, 20after4 Reviewed By: 20after4 Maniphest Tasks: T12450 Differential Revision: https://secure.phabricator.com/D17572
This commit is contained in:
parent
699228c73b
commit
e7c76d92d5
1 changed files with 36 additions and 31 deletions
|
@ -6,60 +6,65 @@ final class PhabricatorSearchManagementInitWorkflow
|
||||||
protected function didConstruct() {
|
protected function didConstruct() {
|
||||||
$this
|
$this
|
||||||
->setName('init')
|
->setName('init')
|
||||||
->setSynopsis(pht('Initialize or repair an index.'))
|
->setSynopsis(pht('Initialize or repair a search service.'))
|
||||||
->setExamples('**init**');
|
->setExamples('**init**');
|
||||||
}
|
}
|
||||||
|
|
||||||
public function execute(PhutilArgumentParser $args) {
|
public function execute(PhutilArgumentParser $args) {
|
||||||
$console = PhutilConsole::getConsole();
|
|
||||||
|
|
||||||
$work_done = false;
|
$work_done = false;
|
||||||
foreach (PhabricatorSearchService::getAllServices() as $service) {
|
foreach (PhabricatorSearchService::getAllServices() as $service) {
|
||||||
$console->writeOut(
|
echo tsprintf(
|
||||||
"%s\n",
|
"%s\n",
|
||||||
pht('Initializing search service "%s"', $service->getDisplayName()));
|
pht(
|
||||||
|
'Initializing search service "%s".',
|
||||||
|
$service->getDisplayName()));
|
||||||
|
|
||||||
try {
|
if (!$service->isWritable()) {
|
||||||
$host = $service->getAnyHostForRole('write');
|
echo tsprintf(
|
||||||
} catch (PhabricatorClusterNoHostForRoleException $e) {
|
"%s\n",
|
||||||
// If there are no writable hosts for a given cluster, skip it
|
pht(
|
||||||
$console->writeOut("%s\n", $e->getMessage());
|
'Skipping service "%s" because it is not writable.',
|
||||||
|
$service->getDisplayName()));
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
$engine = $host->getEngine();
|
$engine = $service->getEngine();
|
||||||
|
|
||||||
if (!$engine->indexExists()) {
|
if (!$engine->indexExists()) {
|
||||||
$console->writeOut(
|
echo tsprintf(
|
||||||
'%s',
|
|
||||||
pht('Index does not exist, creating...'));
|
|
||||||
$engine->initIndex();
|
|
||||||
$console->writeOut(
|
|
||||||
"%s\n",
|
"%s\n",
|
||||||
pht('done.'));
|
pht('Service index does not exist, creating...'));
|
||||||
|
|
||||||
|
$engine->initIndex();
|
||||||
$work_done = true;
|
$work_done = true;
|
||||||
} else if (!$engine->indexIsSane()) {
|
} else if (!$engine->indexIsSane()) {
|
||||||
$console->writeOut(
|
echo tsprintf(
|
||||||
'%s',
|
|
||||||
pht('Index exists but is incorrect, fixing...'));
|
|
||||||
$engine->initIndex();
|
|
||||||
$console->writeOut(
|
|
||||||
"%s\n",
|
"%s\n",
|
||||||
pht('done.'));
|
pht('Service index is out of date, repairing...'));
|
||||||
|
|
||||||
|
$engine->initIndex();
|
||||||
$work_done = true;
|
$work_done = true;
|
||||||
|
} else {
|
||||||
|
echo tsprintf(
|
||||||
|
"%s\n",
|
||||||
|
pht('Service index is already up to date.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo tsprintf(
|
||||||
|
"%s\n",
|
||||||
|
pht('Done.'));
|
||||||
}
|
}
|
||||||
|
|
||||||
if ($work_done) {
|
if (!$work_done) {
|
||||||
$console->writeOut(
|
echo tsprintf(
|
||||||
"%s\n",
|
"%s\n",
|
||||||
pht(
|
pht('No services need initialization.'));
|
||||||
'Index maintenance complete. Run `%s` to reindex documents',
|
return 0;
|
||||||
'./bin/search index'));
|
|
||||||
} else {
|
|
||||||
$console->writeOut(
|
|
||||||
"%s\n",
|
|
||||||
pht('Nothing to do.'));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
echo tsprintf(
|
||||||
|
"%s\n",
|
||||||
|
pht('Service initialization complete.'));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue