mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
56 lines
1.8 KiB
PHP
56 lines
1.8 KiB
PHP
<?php
|
||
|
||
// +----------------------------------------------------------------------
|
||
// | ThinkAdmin
|
||
// +----------------------------------------------------------------------
|
||
// | 版权所有 2014~2019 广州楚才信息科技有限公司 [ http://www.cuci.cc ]
|
||
// +----------------------------------------------------------------------
|
||
// | 官方网站: http://demo.thinkadmin.top
|
||
// +----------------------------------------------------------------------
|
||
// | 开源协议 ( https://mit-license.org )
|
||
// +----------------------------------------------------------------------
|
||
// | gitee 代码仓库:https://gitee.com/zoujingli/ThinkAdmin
|
||
// | github 代码仓库:https://github.com/zoujingli/ThinkAdmin
|
||
// +----------------------------------------------------------------------
|
||
|
||
namespace library\queue;
|
||
|
||
use library\service\ProcessService;
|
||
use think\console\Command;
|
||
use think\console\Input;
|
||
use think\console\Output;
|
||
|
||
/**
|
||
* 平滑停止任务的所有进程
|
||
* Class StopQueue
|
||
* @package library\queue
|
||
*/
|
||
class StopQueue extends Command
|
||
{
|
||
|
||
/**
|
||
* 指令属性配置
|
||
*/
|
||
protected function configure()
|
||
{
|
||
$this->setName('xtask:stop')->setDescription('Smooth stop of all task processes');
|
||
}
|
||
|
||
/**
|
||
* 停止所有任务执行
|
||
* @param Input $input
|
||
* @param Output $output
|
||
*/
|
||
protected function execute(Input $input, Output $output)
|
||
{
|
||
$process = ProcessService::instance();
|
||
$command = $process->think('xtask:');
|
||
if (count($result = $process->query($command)) < 1) {
|
||
$output->writeln("There is no task process to finish");
|
||
} else foreach ($result as $item) {
|
||
$process->close($item['pid']);
|
||
$output->writeln("Sending end process {$item['pid']} signal succeeded");
|
||
}
|
||
}
|
||
}
|