13require_once __DIR__ .
'/Maintenance.php';
23 parent::__construct();
24 $this->
addOption(
"group",
"Query group to check specifically" );
25 $this->
addOption(
'cluster',
'Use an external cluster by name',
false,
true );
26 $this->
addDescription(
'Report the hostname of a replica DB server' );
33 $lb = $lbf->getExternalLB( $this->
getOption(
'cluster' ) );
34 }
catch ( InvalidArgumentException $e ) {
35 $this->
fatalError(
'Error: ' . $e->getMessage() );
38 $lb = $lbf->getMainLB();
41 $group = $this->
getOption(
'group',
false );
42 $index = $lb->getReaderIndex( $group );
43 if ( $index ===
false && $group ) {
45 $index = $lb->getReaderIndex(
false );
47 if ( $index ===
false ) {
48 $this->
fatalError(
'Error: unable to get reader index' );
51 $this->
output( $lb->getServerName( $index ) .
"\n" );
57require_once RUN_MAINTENANCE_IF_MAIN;
Maintenance script that reports the hostname of a replica DB server.
execute()
Do the actual work.
__construct()
Default constructor.
Abstract maintenance class for quickly writing and churning out maintenance scripts with minimal effo...
output( $out, $channel=null)
Throw some output to the user.
fatalError( $msg, $exitCode=1)
Output a message and terminate the current script.
addOption( $name, $description, $required=false, $withArg=false, $shortName=false, $multiOccurrence=false)
Add a parameter to the script.
hasOption( $name)
Checks to see if a particular option was set.
getOption( $name, $default=null)
Get an option, or return the default.
getServiceContainer()
Returns the main service container.
addDescription( $text)
Set the description text.