3 $optionsWithArgs = array( 'fake-job', 'procs' );
4 require( dirname(__FILE__
).'/../commandLine.inc' );
5 require( dirname(__FILE__
).'/gearman.inc' );
7 if ( isset( $options['procs'] ) ) {
8 $procs = $options['procs'];
9 if ( $procs < 1 ||
$procs > 1000 ) {
10 echo "Invalid number of processes, please specify a number between 1 and 1000\n";
13 $fc = new ForkController( $procs, ForkController
::RESTART_ON_ERROR
);
14 if ( $fc->start() != 'child' ) {
20 $args = array( 'localhost' );
23 if ( isset( $options['fake-job'] ) ) {
24 $params = unserialize( $options['fake-job'] );
25 MWGearmanJob
::runNoSwitch( $params );
28 $worker = new NonScaryGearmanWorker( $args );
29 $worker->addAbility( 'mw_job' );
30 $worker->beginWork( 'wfGearmanMonitor' );
32 function wfGearmanMonitor( $idle, $lastJob ) {
33 static $lastSleep = 0;
36 if ( $now - $lastSleep >= $interval ) {
37 wfWaitForSlaves( $interval );