Tech:MediaWiki appserver

MediaWiki application servers (MediaWiki appserver) is a name given to the stack of software which runs Miraheze wikis. It is made up of several components.

Maintenance scripts
Maintenance scripts are used for a variety of different things: imports, maintenance, updating stats, migrations, etc. MediaWiki maintenance are found in. MediaWiki maintenance scripts are not the only ones however, some extensions have their own maintenance scripts which are usually found under. They should be ran on either one of the jobrunner servers.

A full list of maintenance scripts can be found here. Below are the maintenance scripts that are most frequently used on Miraheze. Other frequently used maintenance scripts can be found on the specific guides below.


 * importDump.php - allows sysadmins to import XML dumps that are too large for Special:Import on-wiki.
 * should be used for interwiki imports for proper attribution
 * should be used for interwiki imports for proper attribution


 * initSiteStats.php - if Special:Statistics isn't updating properly, it's useful to run this


 * deleteBatch.php - to delete a large number of pages based on a text file


 * sql.php - self explanatory, to run SQL commands


 * eval.php - evaluation of MediaWiki objects and functions

foreachwikiindblist
Foreachwikiindblist allows for a maintenance script to be ran on all Miraheze wikis.

Usage:

mwscript
mwscript allows for faster running of maintenance scripts and automatic logging. You must type 'Y' and press enter to execute.


 * Usage:  to run
 * Usage:  to run

Jobrunner
mwtask111 is responsible for running jobs on MediaWiki. As mentioned above, maintenance scripts should be ran on this servers.


 * In order to see how many jobs are currently waiting to be ran on a wiki, you can use the showJobs.php maintenance script (


 * If a large backlog of jobs is created on a wiki, they can be manually ran by a sysadmin with the runJobs.php maintenance script (
 * It is possible to specify the type of jobs that you want to run with . A list of available types can be found here.
 * It is possible to specify the memory limit as well with

Jobrunner is a service, so if it is necessary it may be restarted with

Metrics regarding the jobqueue and type of jobs can be viewed via Grafana.

Nginx
See more about Nginx on the main documentation page: Tech:Nginx

NGINX is a high performance web server which Miraheze uses for all of our services that use HTTP.

Firejail
There are many extensions currently installed on Miraheze that work by executing external commands (wfShellExec, exec, or Shell::command) to provide media to the extensions (e.g. timelines, videos) or alter other databases. Most of these extensions require third-party libraries to be installed and executed. Unlike MediaWiki extensions these libraries are harder to inspect and maintain for maximum security. A vulnerability in one of those libraries may be discovered anytime, which could lead to remote code execution.

In order to significantly reduce these potential security risks, we use Firejail (an SUID program) to execute those libraries inside sandboxes instead of executing them via the www-data user without further restrictions.

ManageWiki Cache
ManageWiki uses a caching backend for its settings, extensions, permissions and namespaces. This caching system provides that each wiki has a JSON file located in  with this information. In case that there is an issue with the ManageWiki cache for a specific wiki, the following can be used with :

Composer
Composer is a dependency manager for PHP libraries. MediaWiki itself as well as quite a few extensions make use of Composer. More information about Composer can be found on the MediaWiki.org documentation page. On Miraheze, the Composer dependency is managed with Puppet, and any extensions that use Composer must be added to the Puppet file in order for it to be installed properly.

Profiling
If you want to find out what parts of the code take such a long time to execute, you can profile your web requests. This can be done by appending  to the URL and setting the   header.

Example: $ curl -H 'X-Miraheze-Debug: test101.miraheze.org' 'https://allthetropes.org/wiki/Main_Page?forceprofile=1' | grep '1 - main' -A 450 | less

MediaWiki-related Miraheze Guides

 * Add a new extension
 * Delete a wiki
 * Move a wiki to another database server
 * Remove a MediaWiki Extension
 * Update a MediaWiki Extension
 * How-To upgrade MediaWiki