mirror of
https://gitee.com/zoujingli/ThinkAdmin.git
synced 2025-04-06 03:58:04 +08:00
ComposerUpdate
This commit is contained in:
parent
b13b8e4bfc
commit
f8c0cd8111
8
composer.lock
generated
8
composer.lock
generated
@ -783,12 +783,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "265496e70f48b940c755aeee1c78443662231e80"
|
||||
"reference": "575e803f69555599fbc0914b95012f978da3798f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/265496e70f48b940c755aeee1c78443662231e80",
|
||||
"reference": "265496e70f48b940c755aeee1c78443662231e80",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/575e803f69555599fbc0914b95012f978da3798f",
|
||||
"reference": "575e803f69555599fbc0914b95012f978da3798f",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -832,7 +832,7 @@
|
||||
],
|
||||
"description": "ThinkPHP v6.0 Development Library",
|
||||
"homepage": "http://framework.thinkadmin.top",
|
||||
"time": "2019-11-26T06:05:05+00:00"
|
||||
"time": "2019-11-27T09:48:45+00:00"
|
||||
}
|
||||
],
|
||||
"packages-dev": [],
|
||||
|
8
vendor/composer/installed.json
vendored
8
vendor/composer/installed.json
vendored
@ -805,12 +805,12 @@
|
||||
"source": {
|
||||
"type": "git",
|
||||
"url": "https://github.com/zoujingli/ThinkLibrary.git",
|
||||
"reference": "265496e70f48b940c755aeee1c78443662231e80"
|
||||
"reference": "575e803f69555599fbc0914b95012f978da3798f"
|
||||
},
|
||||
"dist": {
|
||||
"type": "zip",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/265496e70f48b940c755aeee1c78443662231e80",
|
||||
"reference": "265496e70f48b940c755aeee1c78443662231e80",
|
||||
"url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/575e803f69555599fbc0914b95012f978da3798f",
|
||||
"reference": "575e803f69555599fbc0914b95012f978da3798f",
|
||||
"shasum": "",
|
||||
"mirrors": [
|
||||
{
|
||||
@ -826,7 +826,7 @@
|
||||
"ext-json": "*",
|
||||
"topthink/framework": "^6.0"
|
||||
},
|
||||
"time": "2019-11-26T06:05:05+00:00",
|
||||
"time": "2019-11-27T09:48:45+00:00",
|
||||
"type": "library",
|
||||
"extra": {
|
||||
"think": {
|
||||
|
2
vendor/services.php
vendored
2
vendor/services.php
vendored
@ -1,5 +1,5 @@
|
||||
<?php
|
||||
// This file is automatically generated at:2019-11-26 14:54:30
|
||||
// This file is automatically generated at:2019-11-27 18:01:13
|
||||
declare (strict_types = 1);
|
||||
return array (
|
||||
0 => 'think\\app\\Service',
|
||||
|
@ -35,7 +35,7 @@ use think\Request;
|
||||
* Class Controller
|
||||
* @package think\admin
|
||||
*/
|
||||
class Controller extends \stdClass
|
||||
abstract class Controller extends \stdClass
|
||||
{
|
||||
|
||||
/**
|
||||
|
@ -60,7 +60,7 @@ abstract class Helper
|
||||
* @param string|Query $dbQuery
|
||||
* @return Query
|
||||
*/
|
||||
protected function buildQuery($dbQuery)
|
||||
protected function buildQuery($dbQuery): Query
|
||||
{
|
||||
return is_string($dbQuery) ? $this->app->db->name($dbQuery) : $dbQuery;
|
||||
}
|
||||
|
@ -138,7 +138,7 @@ abstract class Storage
|
||||
* 获取所有文件扩展的MINES
|
||||
* @return array
|
||||
*/
|
||||
public static function mimes()
|
||||
public static function mimes(): array
|
||||
{
|
||||
static $mimes = [];
|
||||
if (count($mimes) > 0) return $mimes;
|
||||
|
@ -52,12 +52,20 @@ class Install extends Command
|
||||
*/
|
||||
protected $bind = [
|
||||
'admin' => [
|
||||
'rules' => ['think', 'app/admin'],
|
||||
'rules' => [
|
||||
'think',
|
||||
'app/admin',
|
||||
],
|
||||
'ignore' => [],
|
||||
],
|
||||
'static' => [
|
||||
'rules' => ['public/static'],
|
||||
'ignore' => ['public/static/self'],
|
||||
'rules' => [
|
||||
'public/static/plugs',
|
||||
'public/static/theme',
|
||||
'public/static/admin.js',
|
||||
'public/static/login.js',
|
||||
],
|
||||
'ignore' => [],
|
||||
],
|
||||
];
|
||||
|
||||
@ -76,7 +84,7 @@ class Install extends Command
|
||||
{
|
||||
$this->name = trim($input->getArgument('name'));
|
||||
if (empty($this->name)) {
|
||||
$this->output->error('在线安装的模块名称不能为空!');
|
||||
$this->output->writeln('在线安装的模块名称不能为空!');
|
||||
} else {
|
||||
if (isset($this->bind[$this->name])) {
|
||||
$this->rules = empty($this->bind[$this->name]['rules']) ? [] : $this->bind[$this->name]['rules'];
|
||||
@ -84,7 +92,7 @@ class Install extends Command
|
||||
$this->installFile();
|
||||
$this->installData();
|
||||
} else {
|
||||
$this->output->error("指定模块 {$this->name} 未配置安装规则!");
|
||||
$this->output->writeln("指定模块 {$this->name} 未配置安装规则!");
|
||||
}
|
||||
}
|
||||
}
|
||||
@ -92,17 +100,17 @@ class Install extends Command
|
||||
protected function installFile()
|
||||
{
|
||||
$data = InstallService::instance()->grenerateDifference($this->rules, $this->ignore);
|
||||
if (empty($data)) $this->output->info('文件比对一致不需更新文件!');
|
||||
if (empty($data)) $this->output->writeln('文件比对一致不需更新文件!');
|
||||
else foreach ($data as $file) {
|
||||
list($state, $mode, $name) = InstallService::instance()->fileSynchronization($file);
|
||||
if ($state) {
|
||||
if ($mode === 'add') $this->output->info("--- 下载 {$name} 添加成功");
|
||||
if ($mode === 'mod') $this->output->info("--- 下载 {$name} 更新成功");
|
||||
if ($mode === 'del') $this->output->info("--- 删除 {$name} 文件成功");
|
||||
if ($mode === 'add') $this->output->writeln("--- 下载 {$name} 添加成功");
|
||||
if ($mode === 'mod') $this->output->writeln("--- 下载 {$name} 更新成功");
|
||||
if ($mode === 'del') $this->output->writeln("--- 删除 {$name} 文件成功");
|
||||
} else {
|
||||
if ($mode === 'add') $this->output->error("--- 下载 {$name} 添加失败");
|
||||
if ($mode === 'mod') $this->output->error("--- 下载 {$name} 更新失败");
|
||||
if ($mode === 'del') $this->output->error("--- 删除 {$name} 文件失败");
|
||||
if ($mode === 'add') $this->output->writeln("--- 下载 {$name} 添加失败");
|
||||
if ($mode === 'mod') $this->output->writeln("--- 下载 {$name} 更新失败");
|
||||
if ($mode === 'del') $this->output->writeln("--- 删除 {$name} 文件失败");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -49,24 +49,37 @@ class ListenQueue extends Command
|
||||
if (($process = ProcessService::instance())->iswin()) {
|
||||
$this->setProcessTitle("ThinkAdmin 监听主进程 {$process->version()}");
|
||||
}
|
||||
$output->comment('============ 任务监听中 ============');
|
||||
$output->writeln('============ 任务监听中 ============');
|
||||
while (true) {
|
||||
foreach ($this->app->db->name('SystemQueue')->where([['status', '=', '1'], ['exec_time', '<=', time()]])->order('exec_time asc')->limit(100)->select() as $vo) {
|
||||
$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, $output) {
|
||||
try {
|
||||
$this->app->db->name('SystemQueue')->where(['code' => $vo['code']])->update(['status' => '2', 'enter_time' => time(), 'exec_desc' => '', 'attempts' => $vo['attempts'] + 1]);
|
||||
$this->update($vo['code'], ['status' => '2', 'enter_time' => time(), 'exec_desc' => '', 'attempts' => $vo['attempts'] + 1]);
|
||||
if ($process->query($command = $process->think("xtask:_work {$vo['code']} -"))) {
|
||||
$output->comment("正在执行 -> [{$vo['code']}] {$vo['title']}");
|
||||
$output->writeln("正在执行 -> [{$vo['code']}] {$vo['title']}");
|
||||
} else {
|
||||
$process->create($command);
|
||||
$output->info("创建成功 -> [{$vo['code']}] {$vo['title']}");
|
||||
$output->writeln("创建成功 -> [{$vo['code']}] {$vo['title']}");
|
||||
}
|
||||
} catch (\Exception $e) {
|
||||
$this->app->db->name('SystemQueue')->where(['code' => $vo['code']])->update(['status' => '4', 'outer_time' => time(), 'exec_desc' => $e->getMessage()]);
|
||||
$output->error("创建失败 -> [{$vo['code']}] {$vo['title']},{$e->getMessage()}");
|
||||
$this->update($vo['code'], ['status' => '4', 'outer_time' => time(), 'exec_desc' => $e->getMessage()]);
|
||||
$output->writeln("创建失败 -> [{$vo['code']}] {$vo['title']},{$e->getMessage()}");
|
||||
}
|
||||
}
|
||||
});
|
||||
sleep(1);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* 更新任务数据
|
||||
* @param mixed $code 任务编号
|
||||
* @param mixed $data 任务数据
|
||||
* @return boolean
|
||||
* @throws \think\db\exception\DbException
|
||||
*/
|
||||
protected function update($code, array $data = [])
|
||||
{
|
||||
return $this->app->db->name('SystemQueue')->where(['code' => $code])->update($data);
|
||||
}
|
||||
|
||||
}
|
||||
|
@ -47,14 +47,14 @@ class StartQueue extends Command
|
||||
$process = ProcessService::instance();
|
||||
$command = $process->think("xtask:listen");
|
||||
if (count($result = $process->query($command)) > 0) {
|
||||
$output->info("监听主进程{$result['0']['pid']}已经启动!");
|
||||
$output->writeln("监听主进程{$result['0']['pid']}已经启动!");
|
||||
} else {
|
||||
$process->create($command);
|
||||
sleep(1);
|
||||
if (count($result = $process->query($command)) > 0) {
|
||||
$output->info("监听主进程{$result['0']['pid']}启动成功!");
|
||||
$output->writeln("监听主进程{$result['0']['pid']}启动成功!");
|
||||
} else {
|
||||
$output->error('监听主进程创建失败!');
|
||||
$output->writeln('监听主进程创建失败!');
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -45,9 +45,9 @@ class StateQueue extends Command
|
||||
$process = ProcessService::instance();
|
||||
$command = $process->think('xtask:listen');
|
||||
if (count($result = $process->query($command)) > 0) {
|
||||
$output->info("异步任务监听主进程{$result[0]['pid']}正在运行...");
|
||||
$output->writeln("任务监听主进程{$result[0]['pid']}正在运行...");
|
||||
} else {
|
||||
$output->error("异步任务监听主进程没有运行哦!");
|
||||
$output->writeln("任务监听主进程没有运行哦!");
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -53,10 +53,9 @@ class ProcessService extends Service
|
||||
public function create($command)
|
||||
{
|
||||
if ($this->iswin()) {
|
||||
$command = __DIR__ . "/bin/console.exe {$command}";
|
||||
pclose(popen("wmic process call create \"{$command}\"", 'r'));
|
||||
$this->exec(__DIR__ . "/bin/console.exe {$command}");
|
||||
} else {
|
||||
pclose(popen("{$command} &", 'r'));
|
||||
$this->exec("{$command} &");
|
||||
}
|
||||
return $this;
|
||||
}
|
||||
@ -70,14 +69,14 @@ class ProcessService extends Service
|
||||
{
|
||||
$list = [];
|
||||
if ($this->iswin()) {
|
||||
$result = $this->exec('wmic process where name="php.exe" get processid,CommandLine');
|
||||
foreach (explode("\n", $result) as $line) if ($this->_issub($line, $command) !== false) {
|
||||
$lines = $this->exec('wmic process where name="php.exe" get processid,CommandLine', true);
|
||||
foreach ($lines as $line) if ($this->_issub($line, $command) !== false) {
|
||||
$attr = explode(' ', $this->_space($line));
|
||||
$list[] = ['pid' => array_pop($attr), 'cmd' => join(' ', $attr)];
|
||||
}
|
||||
} else {
|
||||
$result = $this->exec("ps ax|grep -v grep|grep \"{$command}\"");
|
||||
foreach (explode("\n", $result) as $line) if ($this->_issub($line, $command) !== false) {
|
||||
$lines = $this->exec("ps ax|grep -v grep|grep \"{$command}\"", true);
|
||||
foreach ($lines as $line) if ($this->_issub($line, $command) !== false) {
|
||||
$attr = explode(' ', $this->_space($line));
|
||||
list($pid) = [array_shift($attr), array_shift($attr), array_shift($attr), array_shift($attr)];
|
||||
$list[] = ['pid' => $pid, 'cmd' => join(' ', $attr)];
|
||||
@ -104,11 +103,13 @@ class ProcessService extends Service
|
||||
/**
|
||||
* 立即执行指令
|
||||
* @param string $command 执行指令
|
||||
* @return string
|
||||
* @param boolean $outarr 返回类型
|
||||
* @return string|array
|
||||
*/
|
||||
public function exec($command)
|
||||
public function exec($command, $outarr = false)
|
||||
{
|
||||
return shell_exec($command);
|
||||
exec($command, $output);
|
||||
return $outarr ? $output : join("\n", $output);
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -162,28 +162,6 @@ class QiniuStorage extends Storage
|
||||
return isset($data['md5']) ? ['file' => $name, 'url' => $this->url($name, $safe), 'hash' => $data['md5'], 'key' => $name] : [];
|
||||
}
|
||||
|
||||
/**
|
||||
* URL安全的Base64编码
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
private function safeBase64($content)
|
||||
{
|
||||
return str_replace(['+', '/'], ['-', '_'], base64_encode($content));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象管理凭证
|
||||
* @param string $name 文件名称
|
||||
* @param string $type 操作类型
|
||||
* @return array
|
||||
*/
|
||||
private function getAccessToken($name, $type = 'state')
|
||||
{
|
||||
$EncodedEntryURI = $this->safeBase64("{$this->bucket}:{$name}");
|
||||
return [$EncodedEntryURI, "{$this->accessKey}:{$this->safeBase64(hash_hmac('sha1', "/{$type}/{$EncodedEntryURI}\n", $this->secretKey, true))}"];
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取文件上传地址
|
||||
* @return string
|
||||
@ -225,4 +203,26 @@ class QiniuStorage extends Storage
|
||||
]));
|
||||
return "{$this->accessKey}:{$this->safeBase64(hash_hmac('sha1', $policy, $this->secretKey, true))}:{$policy}";
|
||||
}
|
||||
|
||||
/**
|
||||
* URL安全的Base64编码
|
||||
* @param string $content
|
||||
* @return string
|
||||
*/
|
||||
private function safeBase64($content)
|
||||
{
|
||||
return str_replace(['+', '/'], ['-', '_'], base64_encode($content));
|
||||
}
|
||||
|
||||
/**
|
||||
* 获取对象管理凭证
|
||||
* @param string $name 文件名称
|
||||
* @param string $type 操作类型
|
||||
* @return array
|
||||
*/
|
||||
private function getAccessToken($name, $type = 'state')
|
||||
{
|
||||
$EncodedEntryURI = $this->safeBase64("{$this->bucket}:{$name}");
|
||||
return [$EncodedEntryURI, "{$this->accessKey}:{$this->safeBase64(hash_hmac('sha1', "/{$type}/{$EncodedEntryURI}\n", $this->secretKey, true))}"];
|
||||
}
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user