27require_once __DIR__ .
'/Maintenance.php';
37 parent::__construct();
38 $this->
addOption(
"group",
"Query group to check specifically" );
39 $this->
addOption(
'cluster',
'Use an external cluster by name',
false,
true );
40 $this->
addDescription(
'Report the hostname of a replica DB server' );
47 $lb = $lbf->getExternalLB( $this->
getOption(
'cluster' ) );
48 }
catch ( InvalidArgumentException $e ) {
49 $this->
fatalError(
'Error: ' . $e->getMessage() );
52 $lb = $lbf->getMainLB();
55 $group = $this->
getOption(
'group',
false );
56 $index = $lb->getReaderIndex( $group );
57 if ( $index ===
false && $group ) {
59 $index = $lb->getReaderIndex(
false );
61 if ( $index ===
false ) {
62 $this->
fatalError(
'Error: unable to get reader index' );
65 $this->
output( $lb->getServerName( $index ) .
"\n" );
71require_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.