Laravel 独立队列 "isDownForMaintenance" 错误
Laravel Queue Standalone "isDownForMaintenance" Error
我将 Laravel 的队列作为独立的队列使用,我得到了 运行 的所有内容,除了这个我不断遇到的错误。
PHP Fatal error: Uncaught Error: Call to undefined method
Illuminate\Container\Container::isDownForMaintenance()
在 Laravel 的论坛上,一年前发布了一个修复程序,但似乎没有用。解决方案是
<?php
use Illuminate\Container\Container as IlluminateContainer;
class Container extends IlluminateContainer {
public function isDownForMaintenance() {
return false;
}
}
没有人对此有解决方案吗?
整个代码为:
<?php
use \Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Queue\Capsule\Manager as QueueManager;
use Illuminate\Redis\Database;
use Illuminate\Queue\Worker;
use Illuminate\Events\Dispatcher;
use Illuminate\Queue\WorkerOptions;
use Illuminate\Container\Container as IlluminateContainer;
require __DIR__ . '/../../../vendor/autoload.php';
//require __DIR__ . '/Main.php';
//require __DIR__ . '/Fix.php';
class Container extends IlluminateContainer
{
public function isDownForMaintenance() {
return false;
}
}
class TasksDomain
{
public function fire($job, $asssetID)
{
// Task for domain
$domain = DomainsMongo::collection('domains')->where('_id', $assetID)->first();
echo $domain->Domain;
}
}
class MyQueueException implements ExceptionHandler
{
/**
* Report or log an exception.
*
* @param \Exception $e
* @return void
*/
public function report(\Exception $e)
{
//处理异常
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Symfony\Component\HttpFoundation\Response
*/
public function render($request, \Exception $e)
{
}
/**
* Render an exception to the console.
*
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param \Exception $e
* @return void
*/
public function renderForConsole($output, \Exception $e)
{
$this->report($e);
}
}
$queue = new QueueManager;
$container = $queue->getContainer();
$container['config']['database.redis'] = [
'client' => 'predis',
'cluster' => false,
'default' => [
'host' => getenv('REDIS_HOST'),
'port' => getenv('REDIS_PORT'),
'password' => getenv('REDIST_PASSWORD'),
'database' => 0,
],
];
$container->singleton('redis', function ($container) {
return new Database($container['config']['database.redis']);
});
$container['config']["queue.connections.redis"] = [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'retry_after' => 30,
];
$queue->addConnection([
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'retry_after' => 30,
]);
$queue->setAsGlobal();
$dispatcher = new Dispatcher();
$worker = new Worker($queue->getQueueManager(), $dispatcher, new IntelX\Library\Tasks\TasksQueueException());
$options = new WorkerOptions();
$options->maxTries = 3;
$options->timeOut = 300;
$worker->daemon('redis', 'default', $options);
找到答案了!我打算 post 为未来的开发人员做这个,因为 LaraCasts 上的解决方案不起作用!
解决方案:
use Illuminate\Container\Container;
use Illuminate\Queue\Capsule\Manager as QueueManager;
class Application extends Container
{
public function isDownForMaintenance()
{
return false;
}
}
$queue = new QueueManager(new Application());
我将 Laravel 的队列作为独立的队列使用,我得到了 运行 的所有内容,除了这个我不断遇到的错误。
PHP Fatal error: Uncaught Error: Call to undefined method Illuminate\Container\Container::isDownForMaintenance()
在 Laravel 的论坛上,一年前发布了一个修复程序,但似乎没有用。解决方案是
<?php
use Illuminate\Container\Container as IlluminateContainer;
class Container extends IlluminateContainer {
public function isDownForMaintenance() {
return false;
}
}
没有人对此有解决方案吗?
整个代码为:
<?php
use \Illuminate\Contracts\Debug\ExceptionHandler;
use Illuminate\Queue\Capsule\Manager as QueueManager;
use Illuminate\Redis\Database;
use Illuminate\Queue\Worker;
use Illuminate\Events\Dispatcher;
use Illuminate\Queue\WorkerOptions;
use Illuminate\Container\Container as IlluminateContainer;
require __DIR__ . '/../../../vendor/autoload.php';
//require __DIR__ . '/Main.php';
//require __DIR__ . '/Fix.php';
class Container extends IlluminateContainer
{
public function isDownForMaintenance() {
return false;
}
}
class TasksDomain
{
public function fire($job, $asssetID)
{
// Task for domain
$domain = DomainsMongo::collection('domains')->where('_id', $assetID)->first();
echo $domain->Domain;
}
}
class MyQueueException implements ExceptionHandler
{
/**
* Report or log an exception.
*
* @param \Exception $e
* @return void
*/
public function report(\Exception $e)
{
//处理异常
}
/**
* Render an exception into an HTTP response.
*
* @param \Illuminate\Http\Request $request
* @param \Exception $e
* @return \Symfony\Component\HttpFoundation\Response
*/
public function render($request, \Exception $e)
{
}
/**
* Render an exception to the console.
*
* @param \Symfony\Component\Console\Output\OutputInterface $output
* @param \Exception $e
* @return void
*/
public function renderForConsole($output, \Exception $e)
{
$this->report($e);
}
}
$queue = new QueueManager;
$container = $queue->getContainer();
$container['config']['database.redis'] = [
'client' => 'predis',
'cluster' => false,
'default' => [
'host' => getenv('REDIS_HOST'),
'port' => getenv('REDIS_PORT'),
'password' => getenv('REDIST_PASSWORD'),
'database' => 0,
],
];
$container->singleton('redis', function ($container) {
return new Database($container['config']['database.redis']);
});
$container['config']["queue.connections.redis"] = [
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'retry_after' => 30,
];
$queue->addConnection([
'driver' => 'redis',
'connection' => 'default',
'queue' => 'default',
'retry_after' => 30,
]);
$queue->setAsGlobal();
$dispatcher = new Dispatcher();
$worker = new Worker($queue->getQueueManager(), $dispatcher, new IntelX\Library\Tasks\TasksQueueException());
$options = new WorkerOptions();
$options->maxTries = 3;
$options->timeOut = 300;
$worker->daemon('redis', 'default', $options);
找到答案了!我打算 post 为未来的开发人员做这个,因为 LaraCasts 上的解决方案不起作用!
解决方案:
use Illuminate\Container\Container;
use Illuminate\Queue\Capsule\Manager as QueueManager;
class Application extends Container
{
public function isDownForMaintenance()
{
return false;
}
}
$queue = new QueueManager(new Application());