本文整理汇总了PHP中Job::pop_type方法的典型用法代码示例。如果您正苦于以下问题:PHP Job::pop_type方法的具体用法?PHP Job::pop_type怎么用?PHP Job::pop_type使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Job
的用法示例。
在下文中一共展示了Job::pop_type方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。
示例1: execute
public function execute() {
global $wgTitle;
if ( $this->hasOption( 'procs' ) ) {
$procs = intval( $this->getOption( 'procs' ) );
if ( $procs < 1 || $procs > 1000 ) {
$this->error( "Invalid argument to --procs", true );
}
$fc = new ForkController( $procs );
if ( $fc->start() != 'child' ) {
exit( 0 );
}
}
$maxJobs = $this->getOption( 'maxjobs', false );
$maxTime = $this->getOption( 'maxtime', false );
$startTime = time();
$type = $this->getOption( 'type', false );
$wgTitle = Title::newFromText( 'RunJobs.php' );
$dbw = wfGetDB( DB_MASTER );
$n = 0;
$conds = '';
if ( $type !== false ) {
$conds = "job_cmd = " . $dbw->addQuotes( $type );
}
while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) {
$offset = 0;
for ( ; ; ) {
$job = !$type ? Job::pop( $offset ) : Job::pop_type( $type );
if ( !$job ) {
break;
}
wfWaitForSlaves( 5 );
$t = microtime( true );
$offset = $job->id;
$status = $job->run();
$t = microtime( true ) - $t;
$timeMs = intval( $t * 1000 );
if ( !$status ) {
$this->runJobsLog( $job->toString() . " t=$timeMs error={$job->error}" );
} else {
$this->runJobsLog( $job->toString() . " t=$timeMs good" );
}
if ( $maxJobs && ++$n > $maxJobs ) {
break 2;
}
if ( $maxTime && time() - $startTime > $maxTime ) {
break 2;
}
}
}
}
示例2: execute
public function execute()
{
global $wgTitle;
if ($this->hasOption('procs')) {
$procs = intval($this->getOption('procs'));
if ($procs < 1 || $procs > 1000) {
$this->error("Invalid argument to --procs", true);
}
$fc = new ForkController($procs);
if ($fc->start() != 'child') {
exit(0);
}
}
$maxJobs = $this->getOption('maxjobs', false);
$maxTime = $this->getOption('maxtime', false);
$startTime = time();
$type = $this->getOption('type', false);
$wgTitle = Title::newFromText('RunJobs.php');
$dbw = wfGetDB(DB_MASTER);
$n = 0;
$conds = '';
if ($type !== false) {
$conds = "job_cmd = " . $dbw->addQuotes($type);
}
while ($dbw->selectField('job', 'job_id', $conds, 'runJobs.php')) {
$offset = 0;
for (;;) {
$job = !$type ? Job::pop($offset) : Job::pop_type($type);
if (!$job) {
break;
}
//check for similar (but not IDENTICAL (different timestamp allowed) jobs and delete them.
$dbw->delete('job', array('job_cmd' => $job->command, 'job_title' => $job->title->getDBkey()), __METHOD__);
wfWaitForSlaves();
$t = microtime(true);
$offset = $job->id;
$status = $job->run();
$t = microtime(true) - $t;
$timeMs = intval($t * 1000);
if (!$status) {
$this->runJobsLog($job->toString() . " t={$timeMs} error={$job->error}");
} else {
$this->runJobsLog($job->toString() . " t={$timeMs} good");
}
if ($maxJobs && ++$n > $maxJobs) {
break 2;
}
if ($maxTime && time() - $startTime > $maxTime) {
break 2;
}
}
}
}
示例3: execute
/**
* Main entry point, tak job from queue and run it
*
* @access public
*/
public function execute()
{
global $wgUser, $wgApiRunJobsPerRequest;
ini_set("memory_limit", -1);
ini_set("max_execution_time", 0);
$result = array();
$done = 0;
#
# check if wiki is not readonly
#
if (!wfReadOnly()) {
$params = $this->extractRequestParams();
if (!$wgUser->isAllowed("runjob")) {
$this->dieUsageMsg(array("cantrunjobs"));
}
#
# api param has precedence
#
if (isset($params["max"])) {
$max = $params["max"];
if (is_numeric($max) && $max > 0 && $max <= 100) {
$this->maxJobs = $max;
}
} elseif (!empty($wgApiRunJobsPerRequest) && is_numeric($wgApiRunJobsPerRequest) && $wgApiRunJobsPerRequest > 0 && $wgApiRunJobsPerRequest <= 100) {
$this->maxJobs = $wgApiRunJobsPerRequest;
}
foreach (range(1, $this->maxJobs) as $counter) {
if (isset($params["type"])) {
$job = Job::pop_type($params["type"]);
} else {
// refreshlinks2 has precedence
$job = Job::pop_type("refreshLinks2");
if (!$job) {
// any job
$job = Job::pop();
}
}
if ($job) {
$status = $job->run();
$result["job"][] = array("id" => $job->id, "type" => $job->command, "status" => $job->toString(), "error" => $job->error);
$done++;
} else {
// there's no job in queue, finish loop, release request
break;
}
}
}
$this->wikiaLog(array("type" => isset($params["type"]) ? $params["type"] : "undefined", "maxJobs" => $this->maxJobs, "done" => $done));
$result["left"] = $this->checkQueue($done);
$this->getResult()->addValue(null, $this->getModuleName(), $result);
$result = array();
}
示例4: wfGetDB
$maxJobs = 10000;
}
$type = false;
if (isset($options['type'])) {
$type = $options['type'];
}
$wgTitle = Title::newFromText('RunJobs.php');
$dbw = wfGetDB(DB_MASTER);
$n = 0;
$conds = '';
if ($type !== false) {
$conds = "job_cmd = " . $dbw->addQuotes($type);
}
while ($dbw->selectField('job', 'job_id', $conds, 'runJobs.php')) {
$offset = 0;
for (;;) {
$job = $type == false ? Job::pop($offset) : Job::pop_type($type);
if ($job == false) {
break;
}
wfWaitForSlaves(5);
print wfTimestamp(TS_DB) . " " . $job->id . " " . $job->toString() . "\n";
$offset = $job->id;
if (!$job->run()) {
print wfTimestamp(TS_DB) . " Error: {$job->error}\n";
}
if ($maxJobs && ++$n > $maxJobs) {
break 2;
}
}
}
示例5: runTranscodeJobs
function runTranscodeJobs(){
$dbw = wfGetDB( DB_MASTER );
$type = 'webVideoTranscode';
// Set the condition to only run the webVideoTranscode
$conds = "job_cmd = " . $dbw->addQuotes( $type );
while ( $dbw->selectField( 'job', 'job_id', $conds, 'runJobs.php' ) ) {
$offset = 0;
for ( ; ; ) {
$job = Job::pop_type( $type );
if ( !$job )
break;
wfWaitForSlaves( 5 );
$t = microtime( true );
$offset = $job->id;
$status = $job->run();
$t = microtime( true ) - $t;
$timeMs = intval( $t * 1000 );
}
}
}