Help:How to add new wiki to the farm

From VGD Wiki Farm
Revision as of 13:07, 4 January 2021 by DataBank (talk | contribs)

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

Login to the server

Open a SSH session:

ssh databank@videogamedatabank.com

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.

under development ...

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