Mediawiki:在wiki farm / family上编辑工作

I've set up a Wiki family consisting of a small number of Wikis that have (and are expected to continue having) low to moderate traffic.

When you run a single MediaWiki, it runs a job on every page request which is nice for keeping links and categories up to date, but I can't get this behaviour to work for a wiki family.

I have a wiki setup with a branching localSettings (depending on the SERVER_NAME) and have despite searching (and asking on Mediawiki) found no way to keep this job behaviour, rather I get jobs queueing up, presumably because the maintenance scripts being automatically run do not know which Wiki they originate from.

Is there a way to fix/circumvent this? I have not found any kind of variable being supplied when the job queue is run that could be passed into the localSettings.php so that the correct settings are loaded and the jobs can run properly.

Generally jobs are run on each page load within context of current Wiki, this means in your case there should be no problems with queue, because your LocalSettings file is branched. Though, in certain circumstances job queue may be overloaded, in this case you will need to disable default queue behavior ( by setting $wgJobRunRate = 0;) and configure maintenance scripts runner in crontab. This can be tricky for branched farm, but i think it will work like that:

* * * * * php /path/to/your/wiki/maintenance/runJobs.php --wiki domainA.com
* * * * * php /path/to/your/wiki/maintenance/runJobs.php --wiki domainB.com
* * * * * php /path/to/your/wiki/maintenance/runJobs.php --wiki domainC.com

In this scenario during script execution two constants will be available in LocalSettings.php: MW_DB and MW_PREFIX (use only MW_DB), so you will need to modify your LocalSettings.php like that:

...
$activeWiki = 'defaultWiki';
$switchVar = $_SERVER['SERVER_NAME'];
if( defined('DO_MAINTENANCE') && defined('MW_DB') ) {
    $switchVar = MW_DB;
}
switch( $switchVar ) {
    ...
}
...

Problem found - the issue was that the wikis were behind a permission gate (just a regular Apache one), and async jobs don't inherit the permissions, so I had to set async jobs to false to solve it.

In case anyone else gets this problem - $wgRunJobsAsync = false; should be added to localSettings.php