Guest User

Untitled

a guest
Jun 24th, 2018
77
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 2.76 KB | None | 0 0
  1. <?php
  2. use IlluminateContainerContainer as IlluminateContainer;
  3.  
  4. class Container extends IlluminateContainer {
  5. public function isDownForMaintenance() {
  6. return false;
  7. }
  8. }
  9.  
  10. <?php
  11.  
  12. use IlluminateContractsDebugExceptionHandler;
  13. use IlluminateQueueCapsuleManager as QueueManager;
  14. use IlluminateRedisDatabase;
  15. use IlluminateQueueWorker;
  16. use IlluminateEventsDispatcher;
  17. use IlluminateQueueWorkerOptions;
  18. use IlluminateContainerContainer as IlluminateContainer;
  19.  
  20. require __DIR__ . '/../../../vendor/autoload.php';
  21. //require __DIR__ . '/Main.php';
  22. //require __DIR__ . '/Fix.php';
  23.  
  24.  
  25. class Container extends IlluminateContainer
  26. {
  27. public function isDownForMaintenance() {
  28. return false;
  29. }
  30. }
  31.  
  32.  
  33. class TasksDomain
  34. {
  35. public function fire($job, $asssetID)
  36. {
  37. // Task for domain
  38. $domain = DomainsMongo::collection('domains')->where('_id', $assetID)->first();
  39. echo $domain->Domain;
  40. }
  41. }
  42.  
  43. class MyQueueException implements ExceptionHandler
  44. {
  45. /**
  46. * Report or log an exception.
  47. *
  48. * @param Exception $e
  49. * @return void
  50. */
  51. public function report(Exception $e)
  52. {
  53. //处理异常
  54. }
  55. /**
  56. * Render an exception into an HTTP response.
  57. *
  58. * @param IlluminateHttpRequest $request
  59. * @param Exception $e
  60. * @return SymfonyComponentHttpFoundationResponse
  61. */
  62. public function render($request, Exception $e)
  63. {
  64. }
  65. /**
  66. * Render an exception to the console.
  67. *
  68. * @param SymfonyComponentConsoleOutputOutputInterface $output
  69. * @param Exception $e
  70. * @return void
  71. */
  72. public function renderForConsole($output, Exception $e)
  73. {
  74. $this->report($e);
  75. }
  76. }
  77.  
  78. $queue = new QueueManager;
  79.  
  80. $container = $queue->getContainer();
  81.  
  82. $container['config']['database.redis'] = [
  83. 'client' => 'predis',
  84. 'cluster' => false,
  85. 'default' => [
  86. 'host' => getenv('REDIS_HOST'),
  87. 'port' => getenv('REDIS_PORT'),
  88. 'password' => getenv('REDIST_PASSWORD'),
  89. 'database' => 0,
  90. ],
  91. ];
  92.  
  93. $container->singleton('redis', function ($container) {
  94. return new Database($container['config']['database.redis']);
  95. });
  96.  
  97. $container['config']["queue.connections.redis"] = [
  98. 'driver' => 'redis',
  99. 'connection' => 'default',
  100. 'queue' => 'default',
  101. 'retry_after' => 30,
  102. ];
  103.  
  104. $queue->addConnection([
  105. 'driver' => 'redis',
  106. 'connection' => 'default',
  107. 'queue' => 'default',
  108. 'retry_after' => 30,
  109. ]);
  110.  
  111. $queue->setAsGlobal();
  112.  
  113. $dispatcher = new Dispatcher();
  114. $worker = new Worker($queue->getQueueManager(), $dispatcher, new IntelXLibraryTasksTasksQueueException());
  115. $options = new WorkerOptions();
  116. $options->maxTries = 3;
  117. $options->timeOut = 300;
  118. $worker->daemon('redis', 'default', $options);
Add Comment
Please, Sign In to add comment