Beispiel #1
0
 /**
  * Execute the console command.
  */
 public function handle()
 {
     $this->reset = $this->option('reset');
     $this->reset_meta = $this->option('reset-meta');
     $this->re_download = $this->option('re-download');
     if ($this->lawsMeta->isEmpty() || $this->reset_meta) {
         $this->lawsMeta->parse($this->re_download);
         if ($this->reset_meta) {
             die;
         }
     }
     $this->discoverNewLaws($this->reset);
     $this->jobsManager->launch(50, 'discover', 'command.lawgrabber.discover', 'discoverDailyLawList');
     $this->jobsManager->launch(50, 'discover', 'command.lawgrabber.discover', 'discoverDailyLawListPage');
     return true;
 }
Beispiel #2
0
 /**
  * Execute console command.
  */
 public function handle()
 {
     if ($this->option('single')) {
         $output = [];
         exec('pgrep -l -f "^php (.*?)artisan start"', $output);
         foreach ($output as $line) {
             $pid = preg_replace('|([0-9]+)(\\s.*)|u', '$1', $line);
             if ($pid != getmypid()) {
                 exec("kill -9 {$pid}");
             }
         }
     }
     if ($this->option('proxies')) {
         $this->workers = $this->option('proxies');
         $this->proxyManager->useProxy(true);
     }
     if ($this->proxyManager->useProxy()) {
         $this->proxyManager->connect($this->workers, $this->option('kill_old_proxies'));
     }
     if ($job_id = $this->option('job')) {
         $job = Job::find($job_id);
         if ($job) {
             $job->execute();
         } else {
             _log("Job {$job_id} is not found.");
         }
         return;
     }
     if (!$this->jobsManager->count()) {
         _log('No jobs found. Initializing a new discovery and download jobs.');
         $this->discoverer->discoverNewLaws();
         $this->downloader->downloadNewLaws();
     }
     $this->jobsManager->launch($this->workers);
 }
Beispiel #3
0
 /**
  * Execute console command.
  */
 public function handle()
 {
     $law_id = $this->argument('law');
     $revision_date = $this->argument('revision');
     $this->reset = $this->option('reset');
     $this->re_download = $this->option('re-download');
     if ($law_id) {
         if ($revision_date && $revision_date != '@') {
             $this->downloadRevision($law_id, $revision_date, $this->re_download);
         } else {
             $this->downloadCard($law_id, $this->re_download);
             if ($revision_date == '@') {
                 $this->downloadRevision($law_id, null, $this->re_download);
             }
         }
     } else {
         if ($this->reset) {
             $this->downloadNewLaws();
         }
         $this->jobsManager->launch(50, 'download');
     }
     return true;
 }