addOption( "group", "Query group to check specifically" ); $this->addDescription( 'Report the hostname of a replica DB server' ); } public function execute() { global $wgAllDBsAreLocalhost; if ( $wgAllDBsAreLocalhost ) { $host = 'localhost'; } elseif ( $this->hasOption( 'group' ) ) { $db = $this->getDB( DB_REPLICA, $this->getOption( 'group' ) ); $host = $db->getServer(); } else { $lb = MediaWikiServices::getInstance()->getDBLoadBalancer(); $i = $lb->getReaderIndex(); $host = $lb->getServerName( $i ); } $this->output( "$host\n" ); } } $maintClass = GetReplicaServer::class; require_once RUN_MAINTENANCE_IF_MAIN;