@recaptime-dev's working patches + fork for Phorge, a community fork of Phabricator. (Upstream dev and stable branches are at upstream/main and upstream/stable respectively.) hq.recaptime.dev/wiki/Phorge
phorge phabricator
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

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

+36 -31
+36 -31
src/applications/search/management/PhabricatorSearchManagementInitWorkflow.php
··· 6 6 protected function didConstruct() { 7 7 $this 8 8 ->setName('init') 9 - ->setSynopsis(pht('Initialize or repair an index.')) 9 + ->setSynopsis(pht('Initialize or repair a search service.')) 10 10 ->setExamples('**init**'); 11 11 } 12 12 13 13 public function execute(PhutilArgumentParser $args) { 14 - $console = PhutilConsole::getConsole(); 15 14 16 15 $work_done = false; 17 16 foreach (PhabricatorSearchService::getAllServices() as $service) { 18 - $console->writeOut( 17 + echo tsprintf( 19 18 "%s\n", 20 - pht('Initializing search service "%s"', $service->getDisplayName())); 19 + pht( 20 + 'Initializing search service "%s".', 21 + $service->getDisplayName())); 21 22 22 - try { 23 - $host = $service->getAnyHostForRole('write'); 24 - } catch (PhabricatorClusterNoHostForRoleException $e) { 25 - // If there are no writable hosts for a given cluster, skip it 26 - $console->writeOut("%s\n", $e->getMessage()); 23 + if (!$service->isWritable()) { 24 + echo tsprintf( 25 + "%s\n", 26 + pht( 27 + 'Skipping service "%s" because it is not writable.', 28 + $service->getDisplayName())); 27 29 continue; 28 30 } 29 31 30 - $engine = $host->getEngine(); 32 + $engine = $service->getEngine(); 31 33 32 34 if (!$engine->indexExists()) { 33 - $console->writeOut( 34 - '%s', 35 - pht('Index does not exist, creating...')); 35 + echo tsprintf( 36 + "%s\n", 37 + pht('Service index does not exist, creating...')); 38 + 36 39 $engine->initIndex(); 37 - $console->writeOut( 38 - "%s\n", 39 - pht('done.')); 40 40 $work_done = true; 41 41 } else if (!$engine->indexIsSane()) { 42 - $console->writeOut( 43 - '%s', 44 - pht('Index exists but is incorrect, fixing...')); 42 + echo tsprintf( 43 + "%s\n", 44 + pht('Service index is out of date, repairing...')); 45 + 45 46 $engine->initIndex(); 46 - $console->writeOut( 47 + $work_done = true; 48 + } else { 49 + echo tsprintf( 47 50 "%s\n", 48 - pht('done.')); 49 - $work_done = true; 51 + pht('Service index is already up to date.')); 50 52 } 53 + 54 + echo tsprintf( 55 + "%s\n", 56 + pht('Done.')); 51 57 } 52 58 53 - if ($work_done) { 54 - $console->writeOut( 55 - "%s\n", 56 - pht( 57 - 'Index maintenance complete. Run `%s` to reindex documents', 58 - './bin/search index')); 59 - } else { 60 - $console->writeOut( 59 + if (!$work_done) { 60 + echo tsprintf( 61 61 "%s\n", 62 - pht('Nothing to do.')); 62 + pht('No services need initialization.')); 63 + return 0; 63 64 } 65 + 66 + echo tsprintf( 67 + "%s\n", 68 + pht('Service initialization complete.')); 64 69 } 65 70 }