function doJobLoop(){
	global $wgJobTypeConfig, $wahJobDelay, $wahRunOnce, $wahStatusOutput;

	//look for jobs (sleep for $wahJobDelay if none found)
	$job = WahJobManager :: getNewJob(false, 'Internal');
	if(!$job && $wahRunOnce == false){
		if($wahStatusOutput)
			print "no jobs found waiting $wahJobDelay \n";
		sleep($wahJobDelay);
		return doJobLoop();
	}elseif(!$job  && $wahRunOnce == true){
		if($wahStatusOutput)
			print "no job found \n";
		return ;
	}

	$jobSet = WahJobManager ::getJobSetById( $job->job_set_id );
	$jobDetails = FormatJson::decode( $job->job_json ) ;

	//get the title (so we can access the source file)
	$fTitle = Title::newFromText( $job->title, $job->ns );
	$file = wfLocalFile( $fTitle );
	$thumbPath = $file->getThumbPath( $jobSet->set_encodekey );
	//make sure the directory is ready:
	wfMkdirParents( $thumbPath, null, __METHOD__ );

	$destTarget = $thumbPath . '.ogg';
	//issue the encoding command
	if($wahStatusOutput) print "Running Encode Command...\n";
	wahDoEncode($file->getPath(), $destTarget, $jobDetails->encodeSettings );

	//once done with encode update the status:
	WahJobManager :: updateJobDone($job);
	//update set done (if only one item in the set)
	$wjm = WahJobManager::newFromSet( $jobSet );
	$percDone = $wjm->getDonePerc();
	if( $percDone == 1 ){
		WahJobManager :: updateSetDone( $jobSet );
	}else{
		if($wahStatusOutput)
			print "job not complete? (might be mixing chunkDuration types?) ";
	}
}
Exemplo n.º 2
-1
 /**
  * Process a newJob req:
  */
 function proccessJobReq()
 {
     if (isset($this->mParams['jobset']) && $this->mParams['jobset']) {
         $job = WahJobManager::getNewJob($this->mParams['jobset']);
     } else {
         $job = WahJobManager::getNewJob();
     }
     if (!$job) {
         return $this->getResult()->addValue(null, $this->getModuleName(), array('nojobs' => true));
     } else {
         $job4Client = array();
         //unpack the $job_json
         $job4Client['job_json'] = FormatJson::decode($job->job_json);
         //we set the job key to job_id _ sha1
         $job4Client['job_key'] = $job->job_id . '_' . sha1($job->job_json);
         $job4Client['job_title'] = $job->title;
         $job4Client['job_ns'] = $job->ns;
         $job4Client['job_set_id'] = $job->job_set_id;
         $tTitle = Title::newFromText($job->title, $job->ns);
         $job4Client['job_fullTitle'] = $tTitle->getFullText();
         //@@todo avoid an api round trip return url here:
         //$job4Client['job_url'] = $file->getFullURL();
         $this->getResult()->addValue(null, $this->getModuleName(), array('job' => $job4Client));
     }
 }