Job queue: Difference between revisions
Jump to navigation
Jump to search
(Created page with "{{Breadcrumbs|align=right|officialwebsite=no|wikipedia=yes}} The '''job queue''' in MediaWiki is a system designed to handle tasks that are too time-consuming or resource-intensive to be performed during a normal web request-response cycle. The job queue allows MediaWiki to defer tasks that do not need immediate execution. This includes operations like updating link tables when templates change, sending notification emails, re-rendering pages after template edits, or...") |
No edit summary |
||
(6 intermediate revisions by one other user not shown) | |||
Line 1: | Line 1: | ||
{{Breadcrumbs|align=right|officialwebsite=no|wikipedia=yes}} | {{Breadcrumbs|align=right|officialwebsite=no|wikipedia=yes|mediawiki=yes}} | ||
The '''job queue''' in MediaWiki is a system designed to handle tasks that are too time-consuming or resource-intensive to be performed during a normal web request-response cycle. | The '''job queue''' in MediaWiki is a system designed to handle tasks that are too time-consuming or resource-intensive to be performed during a normal web request-response cycle. | ||
Line 9: | Line 9: | ||
* https://saintapedia.org/w/api.php?action=query&meta=siteinfo&siprop=statistics | * https://saintapedia.org/w/api.php?action=query&meta=siteinfo&siprop=statistics | ||
* [[Special:ApiSandbox]] | * [[Special:ApiSandbox]] | ||
== Example == | |||
=== Cron job === | |||
<syntaxhighlight lang="bash"> | |||
#!/bin/bash | |||
# Put the MediaWiki installation path on the line below | |||
MW_INSTALL_PATH="/home/www/www.mywikisite.example/mediawiki" | |||
RUN_JOBS="$MW_INSTALL_PATH/maintenance/runJobs.php --maxtime=60" | |||
echo Starting job service... | |||
# Wait a minute after the server starts up to give other processes time to get started | |||
sleep 1 | |||
echo Started. | |||
while true; do | |||
# Job types that need to be run ASAP no matter how many of them are in the queue | |||
# Those jobs should be very "cheap" to run | |||
php $RUN_JOBS --type="enotifNotify" | |||
# Everything else, limit the number of jobs on each batch | |||
# The <tvar name=1>--wait</tvar> parameter will pause the execution here until new jobs are added, | |||
# to avoid running the loop without anything to do | |||
php $RUN_JOBS --wait --maxjobs=20 | |||
# Wait some seconds to let the CPU do other things, like handling web requests, etc. | |||
echo Waiting for 10 seconds... | |||
sleep 10 | |||
done | |||
</syntaxhighlight> | |||
=== Docker === | |||
<nowiki>*</nowiki> * * * * docker exec web php maintenance/runJobs.php --maxjobs 700 --maxtime=55 | |||
sudo crontab -e | |||
== External == | == External == | ||
Line 14: | Line 45: | ||
* https://mwstake.org/w/api.php?action=query&meta=siteinfo&siprop=statistics | * https://mwstake.org/w/api.php?action=query&meta=siteinfo&siprop=statistics | ||
* https://www.mediawiki.org/wiki/Special:ApiSandbox#action=query&format=xml | * https://www.mediawiki.org/wiki/Special:ApiSandbox#action=query&format=xml | ||
* https://www.mediawiki.org/wiki/Manual:$wgDebugLogGroups |
Latest revision as of 19:27, 5 October 2024
|
The job queue in MediaWiki is a system designed to handle tasks that are too time-consuming or resource-intensive to be performed during a normal web request-response cycle.
The job queue allows MediaWiki to defer tasks that do not need immediate execution. This includes operations like updating link tables when templates change, sending notification emails, re-rendering pages after template edits, or any batch processing tasks.
Saintapedia reference
Example
Cron job
#!/bin/bash
# Put the MediaWiki installation path on the line below
MW_INSTALL_PATH="/home/www/www.mywikisite.example/mediawiki"
RUN_JOBS="$MW_INSTALL_PATH/maintenance/runJobs.php --maxtime=60"
echo Starting job service...
# Wait a minute after the server starts up to give other processes time to get started
sleep 1
echo Started.
while true; do
# Job types that need to be run ASAP no matter how many of them are in the queue
# Those jobs should be very "cheap" to run
php $RUN_JOBS --type="enotifNotify"
# Everything else, limit the number of jobs on each batch
# The <tvar name=1>--wait</tvar> parameter will pause the execution here until new jobs are added,
# to avoid running the loop without anything to do
php $RUN_JOBS --wait --maxjobs=20
# Wait some seconds to let the CPU do other things, like handling web requests, etc.
echo Waiting for 10 seconds...
sleep 10
done
Docker
* * * * * docker exec web php maintenance/runJobs.php --maxjobs 700 --maxtime=55
sudo crontab -e