summaryrefslogtreecommitdiff
path: root/maintenance/getSlaveServer.php
blob: 25258267e25a1e5e9d3c168cc547eb2384d9bf85 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
<?php
/**
 * This script reports the hostname of a slave server.
 *
 * @file
 * @ingroup Maintenance
 */

require_once( dirname(__FILE__).'/commandLine.inc' );

if ( $wgAllDBsAreLocalhost ) {
	# Can't fool the backup script
	print "localhost\n";
	exit;
}

if( isset( $options['group'] ) ) {
	$db = wfGetDB( DB_SLAVE, $options['group'] );
	$host = $db->getServer();
} else {
	$lb = wfGetLB();
	$i = $lb->getReaderIndex();
	$host = $lb->getServerName( $i );
}

print "$host\n";