3 $optionsWithArgs = array( 'fake-job', 'procs' );
4 require( dirname(__FILE__
).'/../commandLine.inc' );
5 require( dirname(__FILE__
).'/gearman.inc' );
7 ini_set('memory_limit', '150M' );
9 if ( isset( $options['procs'] ) ) {
10 $procs = $options['procs'];
11 if ( $procs < 1 ||
$procs > 1000 ) {
12 echo "Invalid number of processes, please specify a number between 1 and 1000\n";
15 $fc = new ForkController( $procs, ForkController
::RESTART_ON_ERROR
);
16 if ( $fc->start() != 'child' ) {
22 $args = array( 'localhost' );
25 if ( isset( $options['fake-job'] ) ) {
26 $params = unserialize( $options['fake-job'] );
27 MWGearmanJob
::runNoSwitch( $params );
30 $worker = new NonScaryGearmanWorker( $args );
31 $worker->addAbility( 'mw_job' );
32 $worker->beginWork( 'wfGearmanMonitor' );
34 function wfGearmanMonitor( $idle, $lastJob ) {
35 static $lastSleep = 0;
38 if ( $now - $lastSleep >= $interval ) {
39 wfWaitForSlaves( $interval );