jobqueue changes
[lhc/web/wiklou.git] / maintenance / getSlaveServer.php
index ebeddc4..2525826 100644 (file)
@@ -1,7 +1,28 @@
 <?php
+/**
+ * This script reports the hostname of a slave server.
+ *
+ * @file
+ * @ingroup Maintenance
+ */
 
 require_once( dirname(__FILE__).'/commandLine.inc' );
-$i = $wgLoadBalancer->getReaderIndex();
-print $wgDBservers[$i]['host'] . "\n";
 
-?>
+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";
+
+