Page MenuHomePhabricator

D17572.diff
No OneTemporary

D17572.diff

diff --git a/src/applications/search/management/PhabricatorSearchManagementInitWorkflow.php b/src/applications/search/management/PhabricatorSearchManagementInitWorkflow.php
--- a/src/applications/search/management/PhabricatorSearchManagementInitWorkflow.php
+++ b/src/applications/search/management/PhabricatorSearchManagementInitWorkflow.php
@@ -6,60 +6,65 @@
protected function didConstruct() {
$this
->setName('init')
- ->setSynopsis(pht('Initialize or repair an index.'))
+ ->setSynopsis(pht('Initialize or repair a search service.'))
->setExamples('**init**');
}
public function execute(PhutilArgumentParser $args) {
- $console = PhutilConsole::getConsole();
$work_done = false;
foreach (PhabricatorSearchService::getAllServices() as $service) {
- $console->writeOut(
+ echo tsprintf(
"%s\n",
- pht('Initializing search service "%s"', $service->getDisplayName()));
+ pht(
+ 'Initializing search service "%s".',
+ $service->getDisplayName()));
- try {
- $host = $service->getAnyHostForRole('write');
- } catch (PhabricatorClusterNoHostForRoleException $e) {
- // If there are no writable hosts for a given cluster, skip it
- $console->writeOut("%s\n", $e->getMessage());
+ if (!$service->isWritable()) {
+ echo tsprintf(
+ "%s\n",
+ pht(
+ 'Skipping service "%s" because it is not writable.',
+ $service->getDisplayName()));
continue;
}
- $engine = $host->getEngine();
+ $engine = $service->getEngine();
if (!$engine->indexExists()) {
- $console->writeOut(
- '%s',
- pht('Index does not exist, creating...'));
- $engine->initIndex();
- $console->writeOut(
+ echo tsprintf(
"%s\n",
- pht('done.'));
+ pht('Service index does not exist, creating...'));
+
+ $engine->initIndex();
$work_done = true;
} else if (!$engine->indexIsSane()) {
- $console->writeOut(
- '%s',
- pht('Index exists but is incorrect, fixing...'));
- $engine->initIndex();
- $console->writeOut(
+ echo tsprintf(
"%s\n",
- pht('done.'));
+ pht('Service index is out of date, repairing...'));
+
+ $engine->initIndex();
$work_done = true;
+ } else {
+ echo tsprintf(
+ "%s\n",
+ pht('Service index is already up to date.'));
}
- }
- if ($work_done) {
- $console->writeOut(
+ echo tsprintf(
"%s\n",
- pht(
- 'Index maintenance complete. Run `%s` to reindex documents',
- './bin/search index'));
- } else {
- $console->writeOut(
+ pht('Done.'));
+ }
+
+ if (!$work_done) {
+ echo tsprintf(
"%s\n",
- pht('Nothing to do.'));
+ pht('No services need initialization.'));
+ return 0;
}
+
+ echo tsprintf(
+ "%s\n",
+ pht('Service initialization complete.'));
}
}

File Metadata

Mime Type
text/plain
Expires
Sat, Mar 15, 10:12 AM (2 w, 4 d ago)
Storage Engine
blob
Storage Format
Encrypted (AES-256-CBC)
Storage Handle
7689873
Default Alt Text
D17572.diff (3 KB)

Event Timeline