Question

I am using beanstalkd to queue jobs.

I have a php script written inside my app/Lib/Queue/Beanstalk/workers/DownloadFileWorker.php

<?php
require_once(dirname(__DIR__) . DIRECTORY_SEPARATOR . 'config.php');
class DownloadS3FilesWorker extends PHPQueue\Worker
{
/**
 * @var \PHPQueue\Backend\FS
 */
    static private $dataSource;
    public $factory = null;
    private $queueConfig = array();
    private $queueBackend = 'Beanstalkd';

    public function __construct()
    {
        parent::__construct();
        $this->queueConfig  = EPubConfig::getConfig($this->queueBackend);
        self::$dataSource = \PHPQueue\Base::backendFactory($this->queueBackend, $this->queueConfig);
    }

    /**
     * @param \PHPQueue\Job $jobObject
     */
    public function runJob($jobObject)
    {
        parent::runJob($jobObject);
        $jobData = $jobObject->data;
        App::uses('FileFactory', 'Lib/File');
        $this->factory = new FileFactory($jobData); 
        $this->factory->downloadAllFiles();
        $this->result_data = $jobData;
    }
}

I am getting the following error.

PHP Fatal error:  Class 'App' not found in /var/virtual/someapp/Lib/Queue/Beanstalk/workers/DownloadFileWorker.php on line 27

The FileFactory itself will use many other Cake related classes.

Was it helpful?

Solution

Wrote as a Shell under Console/Command.

Problem solved!

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top