Help:How to add new wiki to the farm

From VGD Wiki Farm
Revision as of 01:37, 5 January 2021 by DataBank (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)

Initial setup

Initially, there were four wikis configured on the farm:

Number Request URI (Path) Sitename Interwiki Database Suffix
0 /w VGD Wiki Farm databank gamewiki_0 _gamewiki0
1 /cyberpunk2077 Cyberpunk 2077 Wiki cyberpunk2077 gamewiki_1 _gamewiki1
2 /minecraft Minecraft Wiki minecraft gamewiki_2 _gamewiki2
3 /farcry6 Far Cry 6 Wiki farcry6 gamewiki_3 _gamewiki3

All wikis are powered by the single deployment of mediawiki located at /var/www/videogamedatabank.com/mediawiki.

Let's see how to add a wiki number 4 for the game Among Us.

Login to the server

On Linux or Mac open a SSH session:

ssh databank@videogamedatabank.com

On windows use putty with the same username / server (port 22).

Create a database

Login to MySQL:

sudo mysql

Please follow the pattern gamewiki_N where N is the next number in the family.

CREATE DATABASE gamewiki_4;

Allow access to the database for the central database user:

GRANT ALL PRIVILEGES ON gamewiki_4.* TO 'gamewiki_0user'@'localhost' WITH GRANT OPTION;

Done!

exit

Prepare the environment

Create a symlink

Please use a simplified, URL friendly game name, eg. amongus for Among Us:

sudo ln -s /var/www/videogamedatabank.com/mediawiki  /var/www/videogamedatabank.com/amongus

Add a rule for a Giant switch

sudo nano /var/www/videogamedatabank.com/mediawiki/LocalSettings.php

Find this line:

 } else {

Insert this piece of code right before it:

 } elseif ( strpos( $callingurl, '/amongus' ) === 0 ) {
        require_once $customizationdir . '/LocalSettings_gamewiki4.php';

Create a separate directory for uploads

sudo mkdir /var/www/videogamedatabank.com/mediawiki/images_gamewiki4
sudo cp /var/www/videogamedatabank.com/mediawiki/images_gamewiki0/.htaccess /var/www/videogamedatabank.com/mediawiki/images_gamewiki4/.htaccess 
sudo chown -R www-data: /var/www/videogamedatabank.com/mediawiki/images_gamewiki4

Copy and adjust configuration

Copy a standard per wiki config:

sudo cp /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/LocalSettings_{gamewiki0,gamewiki4}.php

Copy a custom per wiki config:

sudo cp /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/Special_{gamewiki0,gamewiki4}.php

Open file in editor:

sudo nano /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/LocalSettings_gamewiki4.php

and adjust these guys:

$wgSitename = "Among Us Wiki";
$wgScriptPath = "/amongus";
$wgUploadDirectory = "$IP/images_gamewiki4";
$wgUploadPath = "$wgScriptPath/images_gamewiki4";
$wgDBname = "gamewiki_4";
enableSemantics( 'amongus' );
require_once( 'Special_gamewiki4.php' );

Adjust custom config the similar way:

sudo nano /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/Special_gamewiki4.php

Populate the database

Attention! This procedure will make wiki family unaccessible for a couple of minutes.

Disable normal processing:

sudo mv /var/www/videogamedatabank.com/mediawiki/LocalSettings.php{,.off}

Navigate to:

https://videogamedatabank.com/amongus

and complete the install.

Please, use the name of database, name of wiki, and mysql user and password you specified earlier in LocalSettings_gamewiki4.php.

Download the auto-generated LocalSettings.php and save it somewhere for reference or for learning purposes.

Re-enable normal processing:

sudo mv /var/www/videogamedatabank.com/mediawiki/LocalSettings.php{.off,}

Update database:

sudo php /var/www/videogamedatabank.com/mediawiki/maintenance/update.php --conf /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/LocalSettings_gamewiki4.php

This will create / update tables based on the current set of extensions.

Automate mediawiki job queue processing

Create a job runner

Copy the job runner script:

sudo cp /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/mwjobrunner_{gamewiki0,gamewiki4}

Adjust it accordingly:

sudo nano /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/mwjobrunner_gamewiki4

Example (adjusted lines are highlighted):

#!/bin/bash
MW_INSTALL_PATH=/var/www/videogamedatabank.com/mediawiki
RUNJOBS=$MW_INSTALL_PATH/maintenance/runJobs.php
CONFIG=$MW_INSTALL_PATH/extensions/wikivisor/LocalSettings_gamewiki4.php
echo Starting job service...
sleep 60
echo Started.
while true; do
        echo Processing Among Us Wiki ...
        php $RUNJOBS --type="enotifNotify" --conf $CONFIG
        php $RUNJOBS --wait --maxjobs=50 --conf $CONFIG
        echo Waiting for 10 seconds...
        sleep 10
done

Symlink it to the system path:

sudo ln -s /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/mwjobrunner_gamewiki4 /usr/local/bin/

Create a system service

Copy the system service definition:

sudo cp /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/mw-jobqueue_{gamewiki0,gamewiki4}.service

Adjust it accordingly:

sudo nano /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/mw-jobqueue_gamewiki4.service

Example (adjusted lines are highlighted):

[Unit]
Description=MediaWiki Job runner service - Among Us

[Service]
ExecStart=/usr/local/bin/mwjobrunner_gamewiki4
Nice=10
ProtectSystem=full
User=www-data
OOMScoreAdjust=200
StandardOutput=journal

[Install]
WantedBy=multi-user.target

Symlink it to the system path:

sudo ln -s /var/www/videogamedatabank.com/mediawiki/extensions/wikivisor/mw-jobqueue_gamewiki4.service /etc/systemd/system

Enable the service:

sudo systemctl enable mw-jobqueue_gamewiki4.service

Start the service:

sudo systemctl start mw-jobqueue_gamewiki4.service

Check the service is running:

sudo systemctl status mw-jobqueue_gamewiki4.service

Follow the service log:

sudo journalctl -f -u mw-jobqueue_gamewiki4.service

Create Interwiki

Pages of all wikis may be easily linked from the newly created Among Us Wiki by prefixes, for example, [[minecraft:Main Page|Minecraft]] will produce the link to the Minecraft Wiki main page: Minecraft.

To make it possible, navigate to Special:Interwiki as admin and add records for all wikis within the farm [1]

Click on Add an interwiki or language prefix and set a prefix, URL and forward rule.

Prefix URL Forward
cyberpunk2077 https://videogamedatabank.com/cyberpunk2077 yes
minecraft https://videogamedatabank.com/minecraft yes
farcry6 https://videogamedatabank.com/farcry6 yes
databank https://videogamedatabank.com/w yes

Then navigate to the respective Special:Interwiki of other wikis and add the Among Us prefix to all of them.

Prefix URL Forward
amongus https://videogamedatabank.com/amongus yes

Include uploaded images into backup

Open crontab schedule:

sudo crontab -e

Copy 16 lines related to any of sister wikis and paste before this line:

50 6 * * * cd /root/gdrive && drive push -no-prompt -fix-clashes

Change suffixes as appropriates and adjust time as needed.

References

  1. Of course, you may want to create an interwiki to absolutely any mediawiki deployment.