Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- use IlluminateContainerContainer as IlluminateContainer;
- class Container extends IlluminateContainer {
- public function isDownForMaintenance() {
- return false;
- }
- }
- <?php
- use IlluminateContractsDebugExceptionHandler;
- use IlluminateQueueCapsuleManager as QueueManager;
- use IlluminateRedisDatabase;
- use IlluminateQueueWorker;
- use IlluminateEventsDispatcher;
- use IlluminateQueueWorkerOptions;
- use IlluminateContainerContainer 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 IlluminateHttpRequest $request
- * @param Exception $e
- * @return SymfonyComponentHttpFoundationResponse
- */
- public function render($request, Exception $e)
- {
- }
- /**
- * Render an exception to the console.
- *
- * @param SymfonyComponentConsoleOutputOutputInterface $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 IntelXLibraryTasksTasksQueueException());
- $options = new WorkerOptions();
- $options->maxTries = 3;
- $options->timeOut = 300;
- $worker->daemon('redis', 'default', $options);
Add Comment
Please, Sign In to add comment