💎一站式轻松地调用各大LLM模型接口,支持GPT4、智谱、星火、月之暗面及文生图 广告
在基础入门中我们看到启动命令,但是启动后任务如何停止?如何查看状态?此处给出基础入门代码。 ***** 1.通用整合命令: ~~~ // 获取命令 $force = empty($_SERVER['argv']['2']) ? '' : $_SERVER['argv']['2']; $command = empty($_SERVER['argv']['1']) ? '' : $_SERVER['argv']['1']; // 配置任务 $task = new Task(); $task->setRunTimePath('./Application/Runtime/'); $task->addFunc(function () { $url = 'https://www.gaojiufeng.cn/?id=271'; @file_get_contents($url); }, 'request', 10, 2);; // 根据命令执行 if ($command == 'start') { $task->start(); } elseif ($command == 'status') { $task->status(); } elseif ($command == 'stop') { $force = ($force == 'force'); //是否强制停止 $task->stop($force); } else { exit('Command is not exist'); } ~~~ 启动任务: php console.php start 查询任务: php console.php status 普通关闭: php console.php stop 强制关闭: php console.php stop force ***** 2.ThinkPHP3.2.3整合命令教程: https://blog.20230611.cn/post/124.html ***** 3.ThinkPHP5.x.x整合命令教程: https://blog.20230611.cn/post/125.html ***** 4.ThinkPHP6.x.x整合命令教程: https://blog.20230611.cn/post/137.html ***** 其他看GITEE文档 ~~~ 普通关闭任务:向守护进程发送退出命令,守护进程安全退出,执行的定时器会本次执行完成后安全退出。全部退出后在日志中能看到。 强制关闭任务:向守护进程发送退出命令,守护进程强制杀死运行中的定时器,然后守护进程自己退出进程。执行完成基本立即全部退出。 ~~~