Files
handbrake-cluster-webui/lib/RippingCluster/Worker.class.php
Ben Roberts 89ddcba363 Renamed the codebase to RippingCluster
Since the new design is engine agnostic, removed HandBrake from the
class names.
2010-08-25 21:46:50 +01:00

48 lines
1.3 KiB
PHP

<?php
class RippingCluster_Worker {
protected $gearman;
public function __construct() {
$this->init();
}
private function init() {
if ($this->gearman) {
return;
}
$config = RippingCluster_Main::instance()->config();
$this->gearman = new GearmanWorker();
$this->gearman->addServers($config->get('rips.job_servers'));
// Load all the plugin classes
echo "Loading Plugins\n";
RippingCluster_Worker_PluginFactory::scan();
foreach (RippingCluster_Worker_PluginFactory::getValidPlugins() as $plugin) {
echo "Grabbing worker functions provided by {$plugin}\n";
$workerFunctions = RippingCluster_Worker_PluginFactory::getPluginWorkerFunctions($plugin);
foreach ($workerFunctions as $function => $callback) {
echo "Adding {$plugin}::{$callback[1]} as {$function}\n";
$this->gearman->addFunction($function, $callback);
}
}
}
public function start() {
while($this->gearman->work()) {
if ($this->gearman->returnCode() != GEARMAN_SUCCESS) {
break;
}
}
return true;
}
}
?>