Solver.php 1.0 KB

123456789101112131415161718192021222324252627282930313233343536373839
  1. <?php
  2. declare (strict_types=1);
  3. namespace app\command;
  4. use think\console\Command;
  5. use think\console\Input;
  6. use think\console\input\Argument;
  7. use think\console\input\Option;
  8. use think\console\Output;
  9. use think\facade\Db;
  10. /**
  11. * 主要处理短信的命令行程序
  12. */
  13. class Solver extends Command {
  14. protected function configure() {
  15. // 指令配置
  16. $this->setName('solver')
  17. ->setDescription('the solver command');
  18. }
  19. protected function execute(Input $input, Output $output) {
  20. // 指令输出
  21. $lockFileName = "task_solver.lock";
  22. $lockFile = fopen($lockFileName, "a");
  23. if (flock($lockFile, LOCK_EX | LOCK_NB)) {//文件锁(独占)
  24. set_time_limit(0);
  25. $schedules = Db::table("new_schedule")->select();
  26. var_dump($info);
  27. flock($lockFile, LOCK_UN);
  28. } else {
  29. $output->writeln('每分钟执行一次,执行时间超过1分钟下个1分钟跳过等待再下1分钟');
  30. }
  31. }
  32. }