Pez
Pez

Reputation: 1299

GearmanBundle doesn't automatically execute jobs for Gearman and Symfony2

I'm positive this is some misconfiguration but I can't seem to find what it is looking through the gearmanbundle and gearman docs.

I've set up Gearman and the gearman PHP extension, and have them running with Symfony2's GearmanBundle.

I can set up jobs and send them to a worker, but the worker isn't automatically executing them, rather it waits for me until I run the app/console gearman:worker:execute command.

Essentially all I want to do is write some images to S3 as a background process so my application doesn't wait for the process to complete before continuing.

When I do run that command it works fine, seems like everything is ok.

Am I running my gearman daemon with the wrong arguments, or, am I missing a configuration somewhere?

Or, do I need to do something like

foreach( $this->gearman->getWorkers() as $worker) {
  $worker->doWork();
}

Or, should I be adding all of these as tasks? Just a little confused I guess.

Thanks a bunch. Here's what the code that calls the worker looks like:

foreach($photos as $photo){

    $payload = array(
        'tempBase64Data' => $photo->getTempBase64Data(),
        'path' => $photo->getPath(),
        'mime' => $photo->getMime(),
    );

    $jobIds[] = $this->gearman->doBackgroundJob(
        'imageWorker~writeFileToS3',
        json_encode($payload)
    );

}

Upvotes: 1

Views: 503

Answers (1)

Pez
Pez

Reputation: 1299

After more research I've found that this is the intended functionality of the GearmanBundle. It will not automatically execute jobs unless you run the execute console command.

I intend to use Supervisor to make sure these workers are always running.

Upvotes: 1

Related Questions