Reputation: 914
Im using multiple workers in my localhost Gearman server machine, where is all my code. Im thinking, if i run this worker elsewhere i must need to move all the the libraries im using to perform this task. Am i right?
Example: In this script im using FILE Class that also uses multiple libraries inside it.
namespace app\controllers;
use app\file\File;
require_once 'vendor/autoload.php';
$worker = new \GearmanWorker();
$worker->addServer();
$worker->addFunction('parse_file', function($job){
echo "entrou no add function!<br>";
print_r ($job->workload());
sleep(2);
new File($job->workload()); # this class parses the files content in database
});
while($worker->work())
{
if ($worker->returnCode() != GEARMAN_SUCCESS)
{
echo "return_code: " . $worker->returnCode() . "\n";
break;
}
}
Upvotes: 2
Views: 364
Reputation: 1025
The answer is yes - you will need a copy of your libraries on each machine the workers will run on. You will need the FILE class and any dependencies.
You only need one copy of the codebase per machine, but you can run multiple instances of workers.
Upvotes: 1