From 3fd45e69451036ab72fbc234f8e9c775f01a6554 Mon Sep 17 00:00:00 2001 From: Anyon Date: Mon, 6 Jan 2020 15:32:48 +0800 Subject: [PATCH] ComposerUpdate --- app/wechat/command/Fans.php | 14 +++--- composer.lock | 8 ++-- vendor/composer/installed.json | 8 ++-- vendor/services.php | 2 +- .../think-library/src/command/Install.php | 47 +++++++++---------- .../think-library/src/command/Version.php | 2 +- .../think-library/src/queue/ListenQueue.php | 39 ++++++++------- .../think-library/src/queue/QueryQueue.php | 4 +- .../think-library/src/queue/StartQueue.php | 8 ++-- .../think-library/src/queue/StateQueue.php | 6 +-- .../think-library/src/queue/StopQueue.php | 6 +-- .../think-library/src/queue/WorkQueue.php | 35 +++++++------- 12 files changed, 92 insertions(+), 87 deletions(-) diff --git a/app/wechat/command/Fans.php b/app/wechat/command/Fans.php index 95afd105d..c84167b97 100644 --- a/app/wechat/command/Fans.php +++ b/app/wechat/command/Fans.php @@ -39,7 +39,7 @@ class Fans extends Command */ protected function configure() { - $this->setName('xadmin:fansall')->setDescription('[获取]同步远程的微信用户'); + $this->setName('xadmin:fansall')->setDescription('Synchronize all wechat user data'); } /** @@ -74,7 +74,7 @@ class Fans extends Command protected function _list($next = '', $done = 0) { $appid = WechatService::instance()->getAppid(); - $this->output->comment('--> 开始同步微信粉丝数据'); + $this->output->comment('--> Start to synchronize wechat user data'); while (!is_null($next) && is_array($result = WechatService::WeChatUser()->getUserList($next)) && !empty($result['data']['openid'])) { foreach (array_chunk($result['data']['openid'], 100) as $openids) { if (is_array($list = WechatService::WeChatUser()->getBatchUserInfo($openids)) && !empty($list['user_info_list'])) { @@ -87,7 +87,7 @@ class Fans extends Command } $next = $result['total'] > $done ? $result['next_openid'] : null; } - $this->output->comment('--> 微信粉丝数据同步完成!'); + $this->output->comment('--> Wechat user data synchronization completed'); $this->output->newLine(); return "同步{$done}个用户数据"; } @@ -104,7 +104,7 @@ class Fans extends Command public function _black($next = '', $done = 0) { $wechat = WechatService::WeChatUser(); - $this->output->comment('--> 开始同步微信黑名单数据'); + $this->output->comment('--> Start to synchronize wechat blacklist data'); while (!is_null($next) && is_array($result = $wechat->getBlackList($next)) && !empty($result['data']['openid'])) { $done += $result['count']; foreach (array_chunk($result['data']['openid'], 100) as $chunk) { @@ -113,7 +113,7 @@ class Fans extends Command $this->output->writeln("--> 共计同步微信黑名单{$result['total']}人"); $next = $result['total'] > $done ? $result['next_openid'] : null; } - $this->output->comment('--> 微信黑名单数据同步完成!'); + $this->output->comment('--> Wechat blacklist data synchronization completed'); $this->output->newLine(); if (empty($result['total'])) { return ',其中黑名单0人'; @@ -136,7 +136,7 @@ class Fans extends Command public function _tags($index = 0) { $appid = WechatService::instance()->getAppid(); - $this->output->comment('--> 同步微信粉丝标签数据'); + $this->output->comment('--> Start to synchronize wechat tag data'); if (is_array($list = WechatService::WeChatTags()->getTags()) && !empty($list['tags'])) { $count = count($list['tags']); foreach ($list['tags'] as &$tag) { @@ -147,7 +147,7 @@ class Fans extends Command $this->app->db->name('WechatFansTags')->where(['appid' => $appid])->delete(); $this->app->db->name('WechatFansTags')->insertAll($list['tags']); } - $this->output->comment('--> 微信粉丝标签数据同步完成!'); + $this->output->comment('--> Wechat tag data synchronization completed'); $this->output->newLine(); return ",同步{$index}个标签。"; } diff --git a/composer.lock b/composer.lock index a7111f3b1..e242b535b 100644 --- a/composer.lock +++ b/composer.lock @@ -909,12 +909,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "914e2daea5331fef86be45433b0d1d891a099685" + "reference": "cfd590be48a94d97e986cc67e2043a8b96611371" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/914e2daea5331fef86be45433b0d1d891a099685", - "reference": "914e2daea5331fef86be45433b0d1d891a099685", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/cfd590be48a94d97e986cc67e2043a8b96611371", + "reference": "cfd590be48a94d97e986cc67e2043a8b96611371", "shasum": "", "mirrors": [ { @@ -958,7 +958,7 @@ ], "description": "ThinkPHP v6.0 Development Library", "homepage": "http://framework.thinkadmin.top", - "time": "2020-01-02T02:10:03+00:00" + "time": "2020-01-06T07:30:03+00:00" }, { "name": "zoujingli/wechat-developer", diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json index daaa1198c..7d136e64d 100644 --- a/vendor/composer/installed.json +++ b/vendor/composer/installed.json @@ -935,12 +935,12 @@ "source": { "type": "git", "url": "https://github.com/zoujingli/ThinkLibrary.git", - "reference": "914e2daea5331fef86be45433b0d1d891a099685" + "reference": "cfd590be48a94d97e986cc67e2043a8b96611371" }, "dist": { "type": "zip", - "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/914e2daea5331fef86be45433b0d1d891a099685", - "reference": "914e2daea5331fef86be45433b0d1d891a099685", + "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/cfd590be48a94d97e986cc67e2043a8b96611371", + "reference": "cfd590be48a94d97e986cc67e2043a8b96611371", "shasum": "", "mirrors": [ { @@ -956,7 +956,7 @@ "ext-json": "*", "topthink/framework": "^6.0" }, - "time": "2020-01-02T02:10:03+00:00", + "time": "2020-01-06T07:30:03+00:00", "type": "library", "extra": { "think": { diff --git a/vendor/services.php b/vendor/services.php index cfc42ddf9..8be36a0d9 100644 --- a/vendor/services.php +++ b/vendor/services.php @@ -1,5 +1,5 @@ 'think\\app\\Service', diff --git a/vendor/zoujingli/think-library/src/command/Install.php b/vendor/zoujingli/think-library/src/command/Install.php index 715866e7d..c66c20209 100644 --- a/vendor/zoujingli/think-library/src/command/Install.php +++ b/vendor/zoujingli/think-library/src/command/Install.php @@ -28,6 +28,13 @@ use think\console\Output; */ class Install extends Command { + + /** + * 指定模块名称 + * @var string + */ + protected $name; + /** * 查询规则 * @var array @@ -40,12 +47,6 @@ class Install extends Command */ protected $ignore = []; - /** - * 指定模块名称 - * @var string - */ - protected $name; - /** * 规则配置 * @var array @@ -73,41 +74,39 @@ class Install extends Command protected function configure() { $this->setName('xadmin:install'); - $this->setDescription("[系统]安装或更新指定模块"); - $this->addArgument('name', Argument::OPTIONAL, '模块名称', ''); + $this->setDescription("Install or update thinkamdin module"); + $this->addArgument('name', Argument::OPTIONAL, 'ModuleName', ''); } protected function execute(Input $input, Output $output) { $this->name = trim($input->getArgument('name')); if (empty($this->name)) { - $this->output->writeln('在线安装的模块名称不能为空!'); + $this->output->writeln('Module name of online installation cannot be empty'); + } elseif (isset($this->bind[$this->name])) { + $this->rules = empty($this->bind[$this->name]['rules']) ? [] : $this->bind[$this->name]['rules']; + $this->ignore = empty($this->bind[$this->name]['ignore']) ? [] : $this->bind[$this->name]['ignore']; + $this->installFile(); + $this->installData(); } else { - if (isset($this->bind[$this->name])) { - $this->rules = empty($this->bind[$this->name]['rules']) ? [] : $this->bind[$this->name]['rules']; - $this->ignore = empty($this->bind[$this->name]['ignore']) ? [] : $this->bind[$this->name]['ignore']; - $this->installFile(); - $this->installData(); - } else { - $this->output->writeln("指定模块 {$this->name} 未配置安装规则!"); - } + $this->output->writeln("The specified module {$this->name} is not configured with installation rules"); } } protected function installFile() { $data = InstallService::instance()->grenerateDifference($this->rules, $this->ignore); - if (empty($data)) $this->output->writeln('文件比对一致不需更新文件!'); + if (empty($data)) $this->output->writeln('No need to update the file if the file comparison is consistent'); else foreach ($data as $file) { list($state, $mode, $name) = InstallService::instance()->fileSynchronization($file); if ($state) { - if ($mode === 'add') $this->output->writeln("--- 下载 {$name} 添加成功"); - if ($mode === 'mod') $this->output->writeln("--- 下载 {$name} 更新成功"); - if ($mode === 'del') $this->output->writeln("--- 删除 {$name} 文件成功"); + if ($mode === 'add') $this->output->writeln("--- {$name} added successfully"); + if ($mode === 'mod') $this->output->writeln("--- {$name} updated successfully"); + if ($mode === 'del') $this->output->writeln("--- {$name} deleted successfully"); } else { - if ($mode === 'add') $this->output->writeln("--- 下载 {$name} 添加失败"); - if ($mode === 'mod') $this->output->writeln("--- 下载 {$name} 更新失败"); - if ($mode === 'del') $this->output->writeln("--- 删除 {$name} 文件失败"); + if ($mode === 'add') $this->output->writeln("--- {$name} add failed"); + if ($mode === 'mod') $this->output->writeln("--- {$name} update failed"); + if ($mode === 'del') $this->output->writeln("--- {$name} delete failed"); } } } diff --git a/vendor/zoujingli/think-library/src/command/Version.php b/vendor/zoujingli/think-library/src/command/Version.php index f8ba8531c..c3dd40b86 100644 --- a/vendor/zoujingli/think-library/src/command/Version.php +++ b/vendor/zoujingli/think-library/src/command/Version.php @@ -31,7 +31,7 @@ class Version extends Command protected function configure() { $this->setName('xadmin:version'); - $this->setDescription("[系统]查看当前框架版本号"); + $this->setDescription("Query application framework version"); } protected function execute(Input $input, Output $output) diff --git a/vendor/zoujingli/think-library/src/queue/ListenQueue.php b/vendor/zoujingli/think-library/src/queue/ListenQueue.php index 31a9b7488..900f1a3ad 100644 --- a/vendor/zoujingli/think-library/src/queue/ListenQueue.php +++ b/vendor/zoujingli/think-library/src/queue/ListenQueue.php @@ -16,6 +16,7 @@ namespace think\admin\queue; use think\admin\service\ProcessService; +use think\Collection; use think\console\Command; use think\console\Input; use think\console\Output; @@ -27,44 +28,48 @@ use think\console\Output; */ class ListenQueue extends Command { + + /** + * 当前任务服务 + * @var ProcessService + */ + protected $process; + /** * 配置指定信息 */ protected function configure() { - $this->setName('xtask:listen')->setDescription('[监听]启动任务监听主进程'); + $this->setName('xtask:listen')->setDescription('Start task listening main process'); } /** * 启动进程守护监听 * @param Input $input 输入对象 * @param Output $output 输出对象 - * @throws \think\db\exception\DataNotFoundException - * @throws \think\db\exception\DbException - * @throws \think\db\exception\ModelNotFoundException */ protected function execute(Input $input, Output $output) { set_time_limit(0); $this->app->db->name('SystemQueue')->count(); - if (($process = ProcessService::instance())->iswin()) { - $this->setProcessTitle("ThinkAdmin 监听主进程 {$process->version()}"); + if (($this->process = ProcessService::instance())->iswin()) { + $this->setProcessTitle("ThinkAdmin {$this->process->version()} Queue Listen"); } - $output->writeln('============ 任务监听中 ============'); + $output->writeln('============ LISTENING ============'); while (true) { $where = [['status', '=', '1'], ['exec_time', '<=', time()]]; - $this->app->db->name('SystemQueue')->where($where)->order('exec_time asc')->limit(100)->select()->each(function ($vo) use ($process) { - try { - $command = $process->think("xtask:_work {$vo['code']} -"); - if (count($process->query($command)) > 0) { - $this->output->warning("正在执行 -> [{$vo['code']}] {$vo['title']}"); + $this->app->db->name('SystemQueue')->where($where)->order('exec_time asc')->chunk(100, function (Collection $list) { + foreach ($list as $vo) try { + $command = $this->process->think("xtask:_work {$vo['code']} -"); + if (count($this->process->query($command)) > 0) { + $this->output->writeln("Already in progress -> [{$vo['code']}] {$vo['title']}"); } else { - $process->create($command); - $this->output->info("开始执行 -> [{$vo['code']}] {$vo['title']}"); + $this->process->create($command); + $this->output->writeln("Created new process -> [{$vo['code']}] {$vo['title']}"); } - } catch (\Exception $e) { - $this->update($vo['code'], ['status' => '4', 'outer_time' => time(), 'exec_desc' => $e->getMessage()]); - $this->output->error("执行失败 -> [{$vo['code']}] {$vo['title']},{$e->getMessage()}"); + } catch (\Exception $exception) { + $this->update($vo['code'], ['status' => '4', 'outer_time' => time(), 'exec_desc' => $exception->getMessage()]); + $this->output->error("Execution failed -> [{$vo['code']}] {$vo['title']},{$exception->getMessage()}"); } }); sleep(1); diff --git a/vendor/zoujingli/think-library/src/queue/QueryQueue.php b/vendor/zoujingli/think-library/src/queue/QueryQueue.php index c18439a72..ce4bff747 100644 --- a/vendor/zoujingli/think-library/src/queue/QueryQueue.php +++ b/vendor/zoujingli/think-library/src/queue/QueryQueue.php @@ -32,7 +32,7 @@ class QueryQueue extends Command */ protected function configure() { - $this->setName('xtask:query')->setDescription('[控制]查询正在运行的进程'); + $this->setName('xtask:query')->setDescription('Query all running task processes'); } /** @@ -47,7 +47,7 @@ class QueryQueue extends Command if (count($result) > 0) foreach ($result as $item) { $output->writeln("{$item['pid']}\t{$item['cmd']}"); } else { - $output->writeln('没有查询到相关任务进程'); + $output->writeln('No related task process found'); } } } diff --git a/vendor/zoujingli/think-library/src/queue/StartQueue.php b/vendor/zoujingli/think-library/src/queue/StartQueue.php index 64a31cf42..5f92043df 100644 --- a/vendor/zoujingli/think-library/src/queue/StartQueue.php +++ b/vendor/zoujingli/think-library/src/queue/StartQueue.php @@ -33,7 +33,7 @@ class StartQueue extends Command */ protected function configure() { - $this->setName('xtask:start')->setDescription('[控制]创建守护监听主进程'); + $this->setName('xtask:start')->setDescription('Create daemons to listening main process'); } /** @@ -47,14 +47,14 @@ class StartQueue extends Command $service = ProcessService::instance(); $command = $service->think("xtask:listen"); if (count($result = $service->query($command)) > 0) { - $output->info("监听主进程{$result['0']['pid']}已经启动!"); + $output->info("Listening main process {$result['0']['pid']} has started"); } else { $service->create($command); sleep(1); if (count($result = $service->query($command)) > 0) { - $output->info("监听主进程{$result['0']['pid']}启动成功!"); + $output->info("Listening main process {$result['0']['pid']} started successfully"); } else { - $output->error('监听主进程创建失败!'); + $output->error('Failed to create listening main process'); } } } diff --git a/vendor/zoujingli/think-library/src/queue/StateQueue.php b/vendor/zoujingli/think-library/src/queue/StateQueue.php index 7f4d98319..b08173436 100644 --- a/vendor/zoujingli/think-library/src/queue/StateQueue.php +++ b/vendor/zoujingli/think-library/src/queue/StateQueue.php @@ -32,7 +32,7 @@ class StateQueue extends Command */ protected function configure() { - $this->setName('xtask:state')->setDescription('[控制]查看监听主进程状态'); + $this->setName('xtask:state')->setDescription('Check listening main process status'); } /** @@ -45,9 +45,9 @@ class StateQueue extends Command $service = ProcessService::instance(); $command = $service->think('xtask:listen'); if (count($result = $service->query($command)) > 0) { - $output->info("任务监听主进程{$result[0]['pid']}正在运行..."); + $output->info("Listening for main process {$result[0]['pid']} running"); } else { - $output->warning("任务监听主进程没有运行哦!"); + $output->warning("The Listening main process is not running"); } } } diff --git a/vendor/zoujingli/think-library/src/queue/StopQueue.php b/vendor/zoujingli/think-library/src/queue/StopQueue.php index acfccc416..b2f445022 100644 --- a/vendor/zoujingli/think-library/src/queue/StopQueue.php +++ b/vendor/zoujingli/think-library/src/queue/StopQueue.php @@ -33,7 +33,7 @@ class StopQueue extends Command */ protected function configure() { - $this->setName('xtask:stop')->setDescription('[控制]平滑停止所有的进程'); + $this->setName('xtask:stop')->setDescription('Smooth stop of all task processes'); } /** @@ -45,10 +45,10 @@ class StopQueue extends Command { $service = ProcessService::instance(); if (count($result = $service->query($service->think('xtask:'))) < 1) { - $output->warning("没有需要结束的任务进程哦!"); + $output->warning("There is no task process to finish"); } else foreach ($result as $item) { $service->close($item['pid']); - $output->info("发送结束进程{$item['pid']}信号成功!"); + $output->info("Sending end process {$item['pid']} signal succeeded"); } } } diff --git a/vendor/zoujingli/think-library/src/queue/WorkQueue.php b/vendor/zoujingli/think-library/src/queue/WorkQueue.php index 875711c11..11b0249f9 100644 --- a/vendor/zoujingli/think-library/src/queue/WorkQueue.php +++ b/vendor/zoujingli/think-library/src/queue/WorkQueue.php @@ -48,9 +48,9 @@ class WorkQueue extends Command */ protected function configure() { - $this->setName('xtask:_work')->setDescription('[执行]创建执行任务的进程'); - $this->addArgument('code', Argument::OPTIONAL, '任务编号'); - $this->addArgument('spts', Argument::OPTIONAL, '指令结束符'); + $this->setName('xtask:_work')->setDescription('Create a process to execute a task'); + $this->addArgument('code', Argument::OPTIONAL, 'TaskNumber'); + $this->addArgument('spts', Argument::OPTIONAL, 'Separator'); } /** @@ -64,20 +64,21 @@ class WorkQueue extends Command set_time_limit(0); $this->code = trim($input->getArgument('code')); if (empty($this->code)) { - $this->output->error('执行任务需要指定任务编号!'); + $this->output->error('Task number needs to be specified for task execution'); } else try { - $queue = $this->app->db->name('SystemQueue')->where(['code' => $this->code, 'status' => '1'])->find(); + $queue = $this->app->db->name($this->table)->where(['code' => $this->code, 'status' => '1'])->find(); if (empty($queue)) { // 这里不做任何处理(该任务可能在其它地方已经在执行) - $this->output->warning($message = "执行任务{$this->code}的或状态异常!"); + $this->output->warning($message = "The or status of task {$this->code} is abnormal"); } else { // 锁定任务状态 - $this->app->db->name('SystemQueue')->where(['code' => $this->code])->update([ - 'status' => '2', 'enter_time' => microtime(true), 'exec_desc' => '', 'attempts' => $this->app->db->raw('attempts+1'), + $this->app->db->name($this->table)->strict(false)->where(['code' => $this->code])->update([ + 'status' => '2', 'enter_time' => microtime(true), 'outer_time' => '0', + 'exec_pid' => getmygid(), 'exec_desc' => '', 'attempts' => $this->app->db->raw('attempts+1'), ]); // 设置进程标题 if (($process = ProcessService::instance())->iswin()) { - $this->setProcessTitle("ThinkAdmin {$process->version()} 执行任务 - {$queue['title']}"); + $this->setProcessTitle("ThinkAdmin {$process->version()} Queue - {$queue['title']}"); } // 执行任务内容 if (class_exists($command = $queue['command'])) { @@ -86,7 +87,7 @@ class WorkQueue extends Command $data = json_decode($queue['data'], true) ?: []; $this->update('3', $command::instance()->initialize($this->code)->execute($data)); } else { - throw new Exception("任务处理类 {$command} 未继承 think\\admin\\service\\QueueService"); + throw new Exception("Task processing class {$command} does not inherit class think\\admin\\service\\QueueService"); } } else { // 自定义指令,不支持返回消息(支持异常结束,异常码可选择 3|4 设置任务状态) @@ -94,11 +95,11 @@ class WorkQueue extends Command $this->update('3', $this->app->console->call(array_shift($attr), $attr, 'console')); } } - } catch (\Exception $e) { - if (in_array($e->getCode(), ['3', '4'])) { - $this->update($e->getCode(), $e->getMessage()); + } catch (\Exception $exception) { + if (in_array($exception->getCode(), ['3', '4'])) { + $this->update($exception->getCode(), $exception->getMessage()); } else { - $this->update('4', $e->getMessage()); + $this->update('4', $exception->getMessage()); } } } @@ -113,11 +114,11 @@ class WorkQueue extends Command protected function update($status, $message) { $desc = explode("\n", trim(is_string($message) ? $message : '')); - $result = $this->app->db->name('SystemQueue')->where(['code' => $this->code])->update([ - 'status' => $status, 'outer_time' => microtime(true), 'exec_desc' => $desc[0], + $result = $this->app->db->name($this->table)->strict(false)->where(['code' => $this->code])->update([ + 'status' => $status, 'outer_time' => microtime(true), 'exec_pid' => getmygid(), 'exec_desc' => $desc[0], ]); $this->output->writeln(is_string($message) ? $message : ''); - return $result !== false; + return $result == false; } }