示例#1
0
 protected function execute(InputInterface $input, OutputInterface $output)
 {
     register_shutdown_function(function () {
         $errfile = 'unknown file';
         $errstr = 'shutdown';
         $errno = E_CORE_ERROR;
         $errline = 0;
         $error = error_get_last();
         if ($error !== NULL) {
             $errno = $error["type"];
             $errfile = $error["file"];
             $errline = $error["line"];
             $errstr = $error["message"];
             Log::info(print_r($error, true));
         }
     });
     $consumer = \Consumer\Consumer::resolve($input->getArgument('consumer'));
     $consumerName = get_class($consumer);
     if ($consumer instanceof \Consumer\IndividualConsumer\IndividualConsumer || $consumer instanceof \Consumer\DatasiftConsumer) {
         $filter = \Consumer\Model\Filter::find($input->getArgument('filter'));
         $output->writeln('Consuming "' . $consumerName . '" with filter "' . $filter->title . '"');
         $consumer->consume($filter);
     } elseif ($consumer instanceof \Consumer\GnipConsumer) {
         $endpoint = $input->getArgument('filter');
         $output->writeln('Consuming "' . $consumerName . '" (' . $endpoint . ')');
         $consumer->setEndpoint($endpoint);
         $consumer->consume(\Consumer\Model\Filter::where('active', 1)->get());
     } else {
         $output->writeln('Consuming "' . $consumerName . '"');
         $consumer->consume(\Consumer\Model\Filter::where('active', 1)->get());
     }
 }
示例#2
0
 private function prepareConsumers()
 {
     // Get all active filters
     $filters = \Consumer\Model\Filter::where('active', 1)->get();
     // Loop through all active consumers
     foreach (explode(',', CONSUMERS) as $consumerName) {
         $consumer = \Consumer\Consumer::resolve($consumerName);
         if ($consumer instanceof \Consumer\IndividualConsumer\IndividualConsumer || $consumer instanceof \Consumer\DatasiftConsumer) {
             foreach ($filters as $filter) {
                 $this->processes[$consumerName . ' - Filter ' . $filter->id] = new \Symfony\Component\Process\Process('./consume work ' . $consumerName . ' ' . $filter->id);
                 $this->processes[$consumerName . ' - Filter ' . $filter->id]->start();
             }
         } else {
             if ($consumer instanceof \Consumer\GnipConsumer) {
                 $publishers = explode(',', GNIP_PUBLISHERS);
                 foreach ($publishers as $publisher) {
                     $this->processes[$consumerName . ' - ' . $publisher] = new \Symfony\Component\Process\Process('./consume work ' . $consumerName . ' ' . $publisher);
                     $this->processes[$consumerName . ' - ' . $publisher]->start();
                 }
             } else {
                 $this->processes[$consumerName] = new \Symfony\Component\Process\Process('./consume work ' . $consumerName);
                 $this->processes[$consumerName]->start();
             }
         }
         $this->output->writeln('<info>' . $consumerName . ':</info> Started');
     }
 }