WorkerCommand.php 1.2 KB

12345678910111213141516171819202122232425262728293031323334353637383940
  1. <?php
  2. // +----------------------------------------------------------------------
  3. // | Niucloud-admin 企业快速开发的saas管理平台
  4. // +----------------------------------------------------------------------
  5. // | 官方网址:https://www.niucloud.com
  6. // +----------------------------------------------------------------------
  7. // | niucloud团队 版权所有 开源版本可自由商用
  8. // +----------------------------------------------------------------------
  9. // | Author: Niucloud Team
  10. // +----------------------------------------------------------------------
  11. namespace app\command;
  12. use think\console\Input;
  13. use think\console\Output;
  14. /**
  15. * worker 兼容think自定义指令
  16. */
  17. trait WorkerCommand
  18. {
  19. public function resetCli(Input $input, Output $output)
  20. {
  21. // 指令输出
  22. $action = $input->getArgument('action');
  23. $mode = $input->getOption('mode');
  24. // 重新构造命令行参数,以便兼容workerman的命令
  25. global $argv;
  26. $argv = [];
  27. array_unshift($argv, 'think', $action);
  28. if ($mode == 'd') {
  29. $argv[] = '-d';
  30. } else if ($mode == 'g') {
  31. $argv[] = '-g';
  32. }
  33. }
  34. }