Command.php 785 B

12345678910111213141516171819202122232425262728293031323334353637
  1. <?php
  2. namespace UCore\Command;
  3. use UCore\Queue\Helper;
  4. /**
  5. * 命令基类
  6. */
  7. abstract class Command extends \Illuminate\Console\Command implements CommandFace
  8. {
  9. use CommandTrait;
  10. /**
  11. * Execute the console command.
  12. *
  13. * @return int
  14. */
  15. public function handle()
  16. {
  17. Helper::add_log('run', 'Console', static::class, []);
  18. $start = microtime(true);
  19. try {
  20. $this->handleRun();
  21. } catch (\Exception $exception) {
  22. $this->callException($exception);
  23. $this->output->error($exception->getMessage());
  24. }
  25. $diff = microtime(true) - $start;
  26. Helper::add_log('run-end', 'Console', static::class, [
  27. 'runtime' => $diff
  28. ], '', $diff);
  29. }
  30. }