Jump to content

Manual:runJobs.php

本頁使用了標題或全文手工轉換
From mediawiki.org
This page is a translated version of the page Manual:RunJobs.php and the translation is 84% complete.
自 MediaWiki 1.40 以來,維護腳本改為直接通過maintenance/run.php 調用。 直接調用維護腳本會觸發警告。

详情

runJobs.php文件是一个维护脚本,用于手动强制运行作业队列。 在正常情况下,队列中的作业作为用户与wiki交互的函数(普通的apache请求)运行。 运行作业的默认速率为1比1,可以通过调整LocalSettings.php 文件中的$wgJobRunRate 进行更改。 请注意,作业的默认内存限制为150 MB,这样坏作业不会占用服务器的所有内存。

您可能希望使用此脚本,因为wiki的流量太慢,无法清除队列,或者可能有大量作业需要清除。 但请注意,对于许多服务器配置,这可能会导致您的wiki在脚本完成之前变得迟钝甚至没有响应。 建议您先尝试50或100,以了解脚本的速度,然后再运行数百个作业或不带参数。

还请注意,如果意外运行了一个脚本,该脚本加载了大量不需要或不需要的作业,也可以通过清除wiki数据库中的job 表来完全清除作业队列。 确保队列中没有您需要的作业,因为所有作业都将被无法恢复地删除。

用法

在MW 1.40版之前
php maintenance/runJobs.php
MW 1.40+
php maintenance/run.php runJobs

高级用法

在MW 1.40版之前
php maintenance/runJobs.php [--conf|--dbpass|--dbuser|--globals|--help|--maxjobs|--maxtime|--memory-limit|--nothrottle|--procs|--quiet|--server|--type|--wait|--wiki]
MW 1.40+
php maintenance/run.php runJobs [--conf|--dbpass|--dbuser|--globals|--help|--maxjobs|--maxtime|--memory-limit|--nothrottle|--procs|--quiet|--server|--type|--wait|--wiki]

通用维护参数

选项/参数 描述
无参数 将运行队列中当前的所有作业
--help (-h) 显示此帮助消息
--quiet (-q) 是否抑制非错误输出
--conf “LocalSettings.php”的位置,如果不是默认值
--wiki 用于指定wiki ID
--globals 在调试处理结束时输出全局变量
--memory-limit 为脚本设置一个特定的内存限制,“max”表示无限制,或“default”以避免更改它
--server 要在URL中使用的协议和服务器名称,例如https://en.wikipedia.org。这有时是必要的,因为在命令行脚本中服务器名称检测可能失败。

脚本相关的参数

选项/参数 描述
--dbuser 用于此脚本的数据库用户
--dbpass 用于此脚本的密码

脚本特定的参数

选项/参数 描述
--maxjobs 要运行的最大作业数
--maxtime 最长挂钟时间(秒)
--procs 要使用的进程数
--type 要运行的作业类型。 有关可用的工作类型,请参见$wgJobClasses
--wait 等待新作业而不是退出
--nothrottle 忽略作业限制配置
--result 设置为“json”以仅打印json响应

Use limits

不建议让"runJobs.php"无限期运行而没有任何限制。 單獨使用 --maxjobs 是不夠的,因此最好與 --maxtime 和/或 --memory-limit 搭配使用。 典型的用法包括定期运行,至少设置一个限制,以防止一次性运行时间过长。

示例

在MW 1.40版之前
php maintenance/runJobs.php --maxjobs 5  --memory-limit 150M --type refreshLinks
MW 1.40+
php maintenance/run.php runJobs --maxjobs 5  --memory-limit 150M --type refreshLinks
在MW 1.40版之前
/home/flowerwiki/public_html/w/maintenance$ php runJobs.php --maxjobs 5 --memory-limit 150M --type refreshLinks
MW 1.40+
/home/flowerwiki/public_html/w/maintenance$ php run.php runJobs --maxjobs 5 --memory-limit 150M --type refreshLinks

執行腳本時,您可能會看到如下輸出,其中包括來自refreshLinks队列的某些工作:

2010-10-29 13:50:38 refreshLinks Daisies STARTING
2010-10-29 13:50:38 refreshLinks Daisies t=501 good
2010-10-29 13:50:38 refreshLinks Magnolias STARTING
2010-10-29 13:50:38 refreshLinks Magnolias t=501 good
2010-10-29 13:50:39 refreshLinks Heirloom_Roses STARTING
2010-10-29 13:50:39 refreshLinks Heirloom_Roses t=500 good
2010-10-29 13:50:39 refreshLinks Carnations STARTING
2010-10-29 13:50:39 refreshLinks Carnations t=501 good
2010-10-29 13:50:40 refreshLinks Tulips STARTING
2010-10-29 13:50:40 refreshLinks Tulips t=563 good


可能的問題

工作队列似乎卡住了

在某些情況下,"runJobs.php"可能會無限期地假當機(hang)。一些工作可能無法完成,從而堵塞队列。

如上所述,最好通過提供必要的旗標來防止這種情況發生,但如果你發現自己處於這種情況,理想情況下,你應該找到問題的原因。 可能的原因包括有

  • 通常是从命令行运行的PHP的php.ini 中缺少了一個PHP扩展。
  • 一個漏洞百出的扩展。

目前尚無標準工具或方法可供您診斷該問題。

物件缓存

如果您啟用了物件快取 "runJobs.php"可能會假當機(hang)。 如果發生這種情況,您可以嘗試以下方法,但請注意以下注意事項。

  1. 建立另一個"LocalSettings.php"檔案,並關閉物件快取功能:
    $wgMainCacheType = CACHE_NONE;
    
  2. 然后使用--conf参数运行runJobs.phprun.php runJobs以指定禁用缓存的新LocalSettings.php文件的位置。

不建议這種方法,因为某些作业会从物件缓存中清除物件,因为缓存被禁用,所以不会清除物件。 这将导致某些更新不会反映在wiki上。

Terminate a running process

Sometimes, if you cannot find the problem and the job queue is creating overhead, you may have no other choice than to terminate it, possibly at the expense of deleting jobs you might need. If this is the case and you accept the risk, you can try to clear the job that you think is causing trouble, or clear the entire jobs table.

Note that on some control panels that use cronjob automation, clearing jobs may have no visible effect. The process initiated may still appear to hang even if there are no jobs left to execute.

Using a database administration tool
  • Go to your database administration tool (e.g. phpMyAdmin) and locate the job table.
  • If you're lucky, it may just be an active job that is causing trouble and that needs to be cleared. You can locate it by finding the row that has a hash value in the job_token column.
  • Repeat if necessary. If all else fails, clear the entire jobs table.
Using manageJobs.php

The maintenance script manageJobs.php does not lend you insights but it does let you delete jobs by group.

参见