0

我正在使用 beanstalkd 来排队作业。

我在我的里面写了一个 php 脚本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;
    }
}

我收到以下错误。

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

FileFactory本身将使用许多其他与 Cake 相关的类。

4

1 回答 1

0

在 Console/Command 下作为 Shell 编写。

问题解决了!

于 2013-10-24T11:12:11.157 回答