r81519 MediaWiki - Code Review archive

Repository:MediaWiki
Revision:r81518‎ | r81519 | r81520 >
Date:15:03, 4 February 2011
Author:demon
Status:ok (Comments)
Tags:
Comment:
Revert r73198 (adding exclusing option to runJobs.php). Per CR, this should use a real pool counter.
Modified paths:
  • /trunk/phase3/maintenance/runJobs.php (modified) (history)

Diff [purge]

Index: trunk/phase3/maintenance/runJobs.php
@@ -2,6 +2,10 @@
33 /**
44 * This script starts pending jobs.
55 *
 6+ * Usage:
 7+ * --maxjobs <num> (default 10000)
 8+ * --type <job_cmd>
 9+ *
610 * This program is free software; you can redistribute it and/or modify
711 * it under the terms of the GNU General Public License as published by
812 * the Free Software Foundation; either version 2 of the License, or
@@ -29,7 +33,6 @@
3034 $this->addOption( 'maxjobs', 'Maximum number of jobs to run', false, true );
3135 $this->addOption( 'type', 'Type of job to run', false, true );
3236 $this->addOption( 'procs', 'Number of processes to use', false, true );
33 - $this->addOption( 'exclusive', 'Run only one exclusive runJobs script at a time. Timeout is 1800 seconds. Useful for cron scripts.', false );
3437 }
3538
3639 public function memoryLimit() {
@@ -38,10 +41,6 @@
3942 }
4043
4144 public function execute() {
42 - if ( $this->lock() === false ) {
43 - exit( 0 );
44 - }
45 -
4645 global $wgTitle;
4746 if ( $this->hasOption( 'procs' ) ) {
4847 $procs = intval( $this->getOption( 'procs' ) );
@@ -50,7 +49,6 @@
5150 }
5251 $fc = new ForkController( $procs );
5352 if ( $fc->start() != 'child' ) {
54 - $this->unlock();
5553 exit( 0 );
5654 }
5755 }
@@ -87,9 +85,6 @@
8886 }
8987 }
9088 }
91 - if ( !$this->hasOption( 'procs' ) ) {
92 - $this->unlock();
93 - }
9489 }
9590
9691 /**
@@ -100,25 +95,6 @@
10196 $this->output( wfTimestamp( TS_DB ) . " $msg\n" );
10297 wfDebugLog( 'runJobs', $msg );
10398 }
104 -
105 - protected function lock() {
106 - if ( $this->hasOption( 'exclusive' ) ) {
107 - $cache = wfGetCache( CACHE_ANYTHING );
108 - $running = $cache->get( wfMemcKey( 'runjobs' ) );
109 - if ( $running ) {
110 - return false;
111 - } else {
112 - $cache->set( wfMemcKey( 'runjobs' ), '1', 1800 );
113 - return true;
114 - }
115 - }
116 - return true;
117 - }
118 -
119 - protected function unlock() {
120 - wfGetCache( CACHE_ANYTHING )->delete( wfMemcKey( 'runjobs' ) );
121 - }
122 -
12399 }
124100
125101 $maintClass = "RunJobs";

Follow-up revisions

RevisionCommit summaryAuthorDate
r81520MFT r81519demon15:06, 4 February 2011

Past revisions this follows-up on

RevisionCommit summaryAuthorDate
r73198Add exclusive option for runJobs.phpnikerabbit08:10, 17 September 2010

Comments

#Comment by Nikerabbit (talk | contribs)   15:54, 7 February 2011

This revert restores the inadequate "usage" section in the top.

The interface should be ok, although there is one problem with the implementation raised in comments in r73198. No working solution has been suggested (using PoolCounter as it is isn't one).

This feature is(was) in use so I'd like to get suggestion soon how to do it properly.

Status & tagging log