Difference between revisions of "Wiki Family"
Jump to navigation
Jump to search
Line 158: | Line 158: | ||
} | } | ||
?> | ?> | ||
+ | </source> | ||
+ | = runjobs = | ||
+ | <source lang='bash'> | ||
+ | #!/bin/bash | ||
+ | # WF 2015-06-08 | ||
+ | # run jobs for all sites | ||
+ | jobs=$(pgrep -fla runjobs | wc -l) | ||
+ | if [ $jobs -gt 3 ] | ||
+ | then | ||
+ | echo "$jobs runjobs already running ..." | ||
+ | exit 1 | ||
+ | fi | ||
+ | cd /srv/www/mediawiki/code | ||
+ | host=$(hostname) | ||
+ | cat $host.sites | egrep -v "^#" | while read siteid site | ||
+ | do | ||
+ | #./update $siteid | ||
+ | #echo $siteid | ||
+ | #echo $site | ||
+ | /usr/bin/php /srv/www/mediawiki/code/worksite.php $site runJobs \ | ||
+ | --conf /srv/www/mediawiki/sites/$site/FullLocalSettings.php >> /var/log/mediawiki/runJobs_$siteid.log 2>&1 | ||
+ | done | ||
</source> | </source> |
Revision as of 08:31, 25 November 2020
Principle
https://www.mediawiki.org/wiki/Manual:Wiki_family
Example Setup
Directory Layout
Localsettings.php (code)
<?php
/**
* MediaWiki wikifamily handling code
*
* Taken from Drupal code to tap multisite configuration.
*/
// returns true if $needle is a substring of $haystack
function contains($needle, $haystack)
{
return strpos($haystack, $needle) !== false;
}
/**
* Find the appropriate configuration directory for the current request
*/
function findConfiguration($confdir,$domain,$debug) {
$host=$_SERVER['SERVER_NAME'];
$host=str_replace(".q.",".",$host);
if ($debug) {
print ("find Configuration for ".$host." in ".$confdir." for domain ".$domain."<br>");
}
if ($host) return $host; else return NULL;
}
/**
* optionally add the given settings
*/
function optionalRequireSettings($settings) {
if (file_exists($settings)) {
require_once($settings);
}
}
# switch on for debuging
$debug=false;
# the main configuration directory in which all wiki farm member sites are configured
$confdir = '/var/www/mediawiki/sites';
# The Prefix to use for local/specialized configuration files
$prefix="BITPlan";
# find the configuration for the current request
$domain="bitplan.com";
$conf=findConfiguration($confdir,$domain,$debug);
#$conf=NULL;
# if we found a configuration then use it
if ($conf) {
# make sure all farm members use the same .smw.json file
# https://www.semantic-mediawiki.org/wiki/Help:$smwgConfigFileDir
global $smwgConfigFileDir;
global $wgWikiFarmSite;
$wgWikiFarmSite=str_replace(".".$domain,"",$conf);
# uncomment for better debugging
if ($debug) {
ini_set('display_errors', '1');
ini_set('display_startup_errors', '1');
error_reporting(E_ALL);
$wgShowExceptionDetails=true;
}
$smwgConfigFileDir = $confdir;
#
# first use the specific LocalSettings for the site
$lsettings="$confdir/$conf/LocalSettings.php";
if ($debug) {
print ("Localsettings from ".$lsettings);
}
require_once( $lsettings );
# then use the global settings for the farm
# if there are further specific settings for the site use them
$gsettings=array("$confdir/{$prefix}Settings.php","$confdir/$conf/{$prefix}Settings.php");
foreach ($gsettings as $gsetting) {
if (file_exists($gsetting)) {
require_once($gsetting);
}
}
} else {
$IP = '.';
require_once( './includes/DefaultSettings.php' ); # used for printing the version
require_once( './includes/NoLocalSettings.php' );
die("wikifarm could not find configuration for $wgServer");
}
?>
runjobs
#!/bin/bash
# WF 2015-06-08
# run jobs for all sites
jobs=$(pgrep -fla runjobs | wc -l)
if [ $jobs -gt 3 ]
then
echo "$jobs runjobs already running ..."
exit 1
fi
cd /srv/www/mediawiki/code
host=$(hostname)
cat $host.sites | egrep -v "^#" | while read siteid site
do
#./update $siteid
#echo $siteid
#echo $site
/usr/bin/php /srv/www/mediawiki/code/worksite.php $site runJobs \
--conf /srv/www/mediawiki/sites/$site/FullLocalSettings.php >> /var/log/mediawiki/runJobs_$siteid.log 2>&1
done