Jump to content
Main menu
Main menu
move to sidebar
hide
Navigation
Main page
Recent changes
Random page
Help about MediaWiki
Numinix MediaWiki Demo
Search
Search
Appearance
Create account
Log in
Personal tools
Create account
Log in
Pages for logged out editors
learn more
Contributions
Talk
Editing
Manual/Job queue
(section)
Page
Discussion
English
Read
Edit
View history
Tools
Tools
move to sidebar
hide
Actions
Read
Edit
View history
General
What links here
Related changes
Special pages
Page information
Appearance
move to sidebar
hide
Warning:
You are not logged in. Your IP address will be publicly visible if you make any edits. If you
log in
or
create an account
, your edits will be attributed to your username, along with other benefits.
Anti-spam check. Do
not
fill this in!
== Set up == <!--T:3--> </translate> <translate><!--T:122--> It is recommended that you schedule the running of jobs completely in the background, via the command line.</translate> If you do not have access to the command line but your hosting plan comes with a web control panel, it may well include a cronjob scheduler. <translate><!--T:4--> By default, jobs are run at the end of a web request. Disable this default behaviour by setting <tvar name=1></tvar> to <tvar name=2><code>0</code></tvar>.</translate> {{note|1=<translate><!--T:99--> You should run <tvar name=1><code>runJobs.php</code></tvar> as the same user as the web server runs as, to ensure that permissions to the filesystem are correctly accounted for if jobs touch uploaded files.</translate>}} <translate> === Cron === <!--T:119--> <!--T:5--> You could use [[w:Cron|cron]] to run the jobs every hour. For instance, add the following to your crontab file: </translate> <syntaxhighlight lang="bash"> 0 * * * * /usr/bin/php /var/www/wiki/maintenance/runJobs.php --maxtime=3600 > /var/log/runJobs.log 2>&1 </syntaxhighlight> <translate> <!--T:120--> Using Cron makes it easy to get started, but can make email notifications and cascading template feel slow (to wait up to an hour). Consider using one of the below approaches to set up a continuous job runner instead. === Continuous service === <!--T:100--> <!--T:101--> If you have shell access and the possibility to create init scripts, you can create a simple service to run jobs as they become available, and also throttle them to prevent the job runner from monopolising the CPU resources of the server: <!--T:102--> Create a bash script, for example at <tvar name=1><code>/usr/local/bin/mwjobrunner</code></tvar>: ==== Create script ==== <!--T:133--> </translate> <syntaxhighlight lang="bash"> #!/bin/bash # <translate nowrap><!--T:103--> Put the MediaWiki installation path on the line below</translate> MW_INSTALL_PATH="/home/www/www.mywikisite.example/mediawiki" RUN_JOBS="$MW_INSTALL_PATH/maintenance/runJobs.php --maxtime=3600" echo <translate nowrap><!--T:104--> Starting job service...</translate> # <translate nowrap><!--T:105--> Wait a minute after the server starts up to give other processes time to get started</translate> sleep 60 echo <translate nowrap><!--T:106--> Started.</translate> while true; do # <translate nowrap><!--T:107--> Job types that need to be run ASAP no matter how many of them are in the queue</translate> # <translate nowrap><!--T:108--> Those jobs should be very "cheap" to run</translate> php $RUN_JOBS --type="enotifNotify" # <translate nowrap><!--T:109--> Everything else, limit the number of jobs on each batch</translate> # <translate nowrap><!--T:110--> 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</translate> php $RUN_JOBS --wait --maxjobs=20 # <translate nowrap><!--T:112--> Wait some seconds to let the CPU do other things, like handling web requests, etc</translate> echo <translate nowrap><!--T:113--> Waiting for 10 seconds...</translate> sleep 10 done </syntaxhighlight> <translate> <!--T:114--> Depending on how fast the server is and the load it handles, you can adapt the number of jobs to run on each cycle and the number of seconds to wait on each cycle. <!--T:115--> Make the script executable (<tvar name=1><code>chmod 755</code></tvar>). ==== Create service ==== <!--T:134--> </translate> <translate><!--T:116--> If using systemd, create a new service unit by creating the file <tvar name=1><code>/etc/systemd/system/mw-jobqueue.service</code></tvar>.</translate> <translate><!--T:117--> Change the <tvar name=1><code>User</code></tvar> parameter to the user that runs PHP on your web server:</translate> <syntaxhighlight lang="ini"> [Unit] Description=MediaWiki Job runner [Service] ExecStart=/usr/local/bin/mwjobrunner Nice=10 ProtectSystem=full User=php-fpm OOMScoreAdjust=200 StandardOutput=journal [Install] WantedBy=multi-user.target </syntaxhighlight> <translate><!--T:118--> Enable it and start it with those commands:</translate> <syntaxhighlight lang="bash"> sudo systemctl enable mw-jobqueue sudo systemctl start mw-jobqueue sudo systemctl status mw-jobqueue </syntaxhighlight> <translate>
Summary:
Please note that all contributions to Numinix MediaWiki Demo may be edited, altered, or removed by other contributors. If you do not want your writing to be edited mercilessly, then do not submit it here.
You are also promising us that you wrote this yourself, or copied it from a public domain or similar free resource (see
Project:Copyrights
for details).
Do not submit copyrighted work without permission!
Cancel
Editing help
(opens in new window)