Page Menu
Home
c4science
Search
Configure Global Search
Log In
Files
F97578487
PhabricatorSearchManagementInitWorkflow.php
No One
Temporary
Actions
Download File
Edit File
Delete File
View Transforms
Subscribe
Mute Notifications
Award Token
Subscribers
None
File Metadata
Details
File Info
Storage
Attached
Created
Sun, Jan 5, 10:17
Size
1 KB
Mime Type
text/x-php
Expires
Tue, Jan 7, 10:17 (2 d)
Engine
blob
Format
Raw Data
Handle
23430228
Attached To
rPH Phabricator
PhabricatorSearchManagementInitWorkflow.php
View Options
<?php
final
class
PhabricatorSearchManagementInitWorkflow
extends
PhabricatorSearchManagementWorkflow
{
protected
function
didConstruct
()
{
$this
->
setName
(
'init'
)
->
setSynopsis
(
pht
(
'Initialize or repair a search service.'
))
->
setExamples
(
'**init**'
);
}
public
function
execute
(
PhutilArgumentParser
$args
)
{
$this
->
validateClusterSearchConfig
();
$work_done
=
false
;
foreach
(
PhabricatorSearchService
::
getAllServices
()
as
$service
)
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Initializing search service "%s".'
,
$service
->
getDisplayName
()));
if
(!
$service
->
isWritable
())
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Skipping service "%s" because it is not writable.'
,
$service
->
getDisplayName
()));
continue
;
}
$engine
=
$service
->
getEngine
();
if
(!
$engine
->
indexExists
())
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Service index does not exist, creating...'
));
$engine
->
initIndex
();
$work_done
=
true
;
}
else
if
(!
$engine
->
indexIsSane
())
{
echo
tsprintf
(
"%s
\n
"
,
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.'
));
}
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Done.'
));
}
if
(!
$work_done
)
{
echo
tsprintf
(
"%s
\n
"
,
pht
(
'No services need initialization.'
));
return
0
;
}
echo
tsprintf
(
"%s
\n
"
,
pht
(
'Service initialization complete.'
));
}
}
Event Timeline
Log In to Comment