diff --git a/app/admin/view/queue/index.html b/app/admin/view/queue/index.html
index 20c743606..0d9fcaae3 100644
--- a/app/admin/view/queue/index.html
+++ b/app/admin/view/queue/index.html
@@ -44,11 +44,11 @@
任务指令:{$vo.command|default=''}
- 创建时间:{$vo.create_at|format_datetime} / {$vo.time|format_datetime}
- 执行时间:{$vo.start_at|format_datetime} / {$vo.end_at|format_datetime}
+ 创建时间:{$vo.create_at|format_datetime} / {$vo.exec_time|format_datetime}
+ 执行时间:{$vo.enter_time|format_datetime} / {$vo.outer_time|format_datetime}
|
- 任务状态:{eq name='vo.double' value='1'}
+ 任务状态:{eq name='vo.rscript' value='1'}
复
{else}
单
@@ -72,7 +72,7 @@
{/if}
- 状态描述:{$vo.desc|raw|default="没有获取到状态描述"}
+ 状态描述:{$vo.exec_desc|raw|default="没有获取到状态描述"}
|
{/foreach}
diff --git a/composer.lock b/composer.lock
index f2728ff35..cabf773e3 100644
--- a/composer.lock
+++ b/composer.lock
@@ -783,12 +783,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
- "reference": "3f65028edaf407d87b5267f81de1fb46c884fed6"
+ "reference": "db1bc2c31e0850dc2b3dfa622757bc69bc19adb3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/3f65028edaf407d87b5267f81de1fb46c884fed6",
- "reference": "3f65028edaf407d87b5267f81de1fb46c884fed6",
+ "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/db1bc2c31e0850dc2b3dfa622757bc69bc19adb3",
+ "reference": "db1bc2c31e0850dc2b3dfa622757bc69bc19adb3",
"shasum": "",
"mirrors": [
{
@@ -832,7 +832,7 @@
],
"description": "ThinkPHP v6.0 Development Library",
"homepage": "http://framework.thinkadmin.top",
- "time": "2019-11-11T02:25:45+00:00"
+ "time": "2019-11-12T02:49:58+00:00"
}
],
"packages-dev": [],
diff --git a/vendor/autoload.php b/vendor/autoload.php
index 0e89b94e0..283095c86 100644
--- a/vendor/autoload.php
+++ b/vendor/autoload.php
@@ -4,4 +4,4 @@
require_once __DIR__ . '/composer/autoload_real.php';
-return ComposerAutoloaderInited8677b0740ec5eab6dc73e204cbc7f9::getLoader();
+return ComposerAutoloaderInitd0e0e12040e0346563a00e9de898c5b7::getLoader();
diff --git a/vendor/composer/autoload_real.php b/vendor/composer/autoload_real.php
index 71dc9c125..64e99fa7c 100644
--- a/vendor/composer/autoload_real.php
+++ b/vendor/composer/autoload_real.php
@@ -2,7 +2,7 @@
// autoload_real.php @generated by Composer
-class ComposerAutoloaderInited8677b0740ec5eab6dc73e204cbc7f9
+class ComposerAutoloaderInitd0e0e12040e0346563a00e9de898c5b7
{
private static $loader;
@@ -19,15 +19,15 @@ class ComposerAutoloaderInited8677b0740ec5eab6dc73e204cbc7f9
return self::$loader;
}
- spl_autoload_register(array('ComposerAutoloaderInited8677b0740ec5eab6dc73e204cbc7f9', 'loadClassLoader'), true, true);
+ spl_autoload_register(array('ComposerAutoloaderInitd0e0e12040e0346563a00e9de898c5b7', 'loadClassLoader'), true, true);
self::$loader = $loader = new \Composer\Autoload\ClassLoader();
- spl_autoload_unregister(array('ComposerAutoloaderInited8677b0740ec5eab6dc73e204cbc7f9', 'loadClassLoader'));
+ spl_autoload_unregister(array('ComposerAutoloaderInitd0e0e12040e0346563a00e9de898c5b7', 'loadClassLoader'));
$useStaticLoader = PHP_VERSION_ID >= 50600 && !defined('HHVM_VERSION') && (!function_exists('zend_loader_file_encoded') || !zend_loader_file_encoded());
if ($useStaticLoader) {
require_once __DIR__ . '/autoload_static.php';
- call_user_func(\Composer\Autoload\ComposerStaticInited8677b0740ec5eab6dc73e204cbc7f9::getInitializer($loader));
+ call_user_func(\Composer\Autoload\ComposerStaticInitd0e0e12040e0346563a00e9de898c5b7::getInitializer($loader));
} else {
$map = require __DIR__ . '/autoload_namespaces.php';
foreach ($map as $namespace => $path) {
@@ -48,19 +48,19 @@ class ComposerAutoloaderInited8677b0740ec5eab6dc73e204cbc7f9
$loader->register(true);
if ($useStaticLoader) {
- $includeFiles = Composer\Autoload\ComposerStaticInited8677b0740ec5eab6dc73e204cbc7f9::$files;
+ $includeFiles = Composer\Autoload\ComposerStaticInitd0e0e12040e0346563a00e9de898c5b7::$files;
} else {
$includeFiles = require __DIR__ . '/autoload_files.php';
}
foreach ($includeFiles as $fileIdentifier => $file) {
- composerRequireed8677b0740ec5eab6dc73e204cbc7f9($fileIdentifier, $file);
+ composerRequired0e0e12040e0346563a00e9de898c5b7($fileIdentifier, $file);
}
return $loader;
}
}
-function composerRequireed8677b0740ec5eab6dc73e204cbc7f9($fileIdentifier, $file)
+function composerRequired0e0e12040e0346563a00e9de898c5b7($fileIdentifier, $file)
{
if (empty($GLOBALS['__composer_autoload_files'][$fileIdentifier])) {
require $file;
diff --git a/vendor/composer/autoload_static.php b/vendor/composer/autoload_static.php
index a2baddbbf..fefecb4de 100644
--- a/vendor/composer/autoload_static.php
+++ b/vendor/composer/autoload_static.php
@@ -4,7 +4,7 @@
namespace Composer\Autoload;
-class ComposerStaticInited8677b0740ec5eab6dc73e204cbc7f9
+class ComposerStaticInitd0e0e12040e0346563a00e9de898c5b7
{
public static $files = array (
'9b552a3cc426e3287cc811caefa3cf53' => __DIR__ . '/..' . '/topthink/think-helper/src/helper.php',
@@ -470,9 +470,9 @@ class ComposerStaticInited8677b0740ec5eab6dc73e204cbc7f9
public static function getInitializer(ClassLoader $loader)
{
return \Closure::bind(function () use ($loader) {
- $loader->prefixLengthsPsr4 = ComposerStaticInited8677b0740ec5eab6dc73e204cbc7f9::$prefixLengthsPsr4;
- $loader->prefixDirsPsr4 = ComposerStaticInited8677b0740ec5eab6dc73e204cbc7f9::$prefixDirsPsr4;
- $loader->classMap = ComposerStaticInited8677b0740ec5eab6dc73e204cbc7f9::$classMap;
+ $loader->prefixLengthsPsr4 = ComposerStaticInitd0e0e12040e0346563a00e9de898c5b7::$prefixLengthsPsr4;
+ $loader->prefixDirsPsr4 = ComposerStaticInitd0e0e12040e0346563a00e9de898c5b7::$prefixDirsPsr4;
+ $loader->classMap = ComposerStaticInitd0e0e12040e0346563a00e9de898c5b7::$classMap;
}, null, ClassLoader::class);
}
diff --git a/vendor/composer/installed.json b/vendor/composer/installed.json
index 7753f5707..2ca52cfb5 100644
--- a/vendor/composer/installed.json
+++ b/vendor/composer/installed.json
@@ -805,12 +805,12 @@
"source": {
"type": "git",
"url": "https://github.com/zoujingli/ThinkLibrary.git",
- "reference": "3f65028edaf407d87b5267f81de1fb46c884fed6"
+ "reference": "db1bc2c31e0850dc2b3dfa622757bc69bc19adb3"
},
"dist": {
"type": "zip",
- "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/3f65028edaf407d87b5267f81de1fb46c884fed6",
- "reference": "3f65028edaf407d87b5267f81de1fb46c884fed6",
+ "url": "https://api.github.com/repos/zoujingli/ThinkLibrary/zipball/db1bc2c31e0850dc2b3dfa622757bc69bc19adb3",
+ "reference": "db1bc2c31e0850dc2b3dfa622757bc69bc19adb3",
"shasum": "",
"mirrors": [
{
@@ -826,7 +826,7 @@
"ext-json": "*",
"topthink/framework": "^6.0"
},
- "time": "2019-11-11T02:25:45+00:00",
+ "time": "2019-11-12T02:49:58+00:00",
"type": "library",
"extra": {
"think": {
diff --git a/vendor/services.php b/vendor/services.php
index 47bb8109c..8adacc5cd 100644
--- a/vendor/services.php
+++ b/vendor/services.php
@@ -1,5 +1,5 @@
'think\\app\\Service',
diff --git a/vendor/zoujingli/think-library/src/Queue.php b/vendor/zoujingli/think-library/src/Queue.php
index 63f91bc32..42377b676 100644
--- a/vendor/zoujingli/think-library/src/Queue.php
+++ b/vendor/zoujingli/think-library/src/Queue.php
@@ -17,8 +17,6 @@ namespace think\admin;
use think\admin\service\ProcessService;
use think\App;
-use think\console\Input;
-use think\console\Output;
/**
* 基础任务基类
@@ -31,25 +29,31 @@ class Queue
* 应用实例
* @var App
*/
- public $app;
+ protected $app;
/**
* 当前任务ID
* @var integer
*/
- public $jobid = 0;
+ protected $jobid = 0;
/**
* 当前任务标题
* @var string
*/
- public $title = '';
+ protected $title = '';
/**
- * 当前任务内容
+ * 当前任务参数
* @var array
*/
- public $queue = [];
+ protected $data = [];
+
+ /**
+ * 当前任务数据
+ * @var array
+ */
+ protected $queue = [];
/**
* Queue constructor.
@@ -96,6 +100,7 @@ class Queue
$this->queue = $this->app->db->name('SystemQueue')->where(['id' => $this->jobid])->find();
if (empty($this->queue)) throw new \think\Exception("Queue {$jobid} Not found.");
$this->title = $this->queue['title'];
+ $this->data = json_decode($this->queue['exec_data'], true) ?: [];
}
return $this;
}
@@ -142,7 +147,7 @@ class Queue
*/
public function register($title, $command, $later = 0, $data = [], $rscript = 1)
{
- $map = [['title', 'eq', $title], ['status', 'in', ['1', '2']]];
+ $map = [['title', '=', $title], ['status', 'in', ['1', '2']]];
if (empty($rscript) && $this->app->db->name('SystemQueue')->where($map)->count() > 0) {
throw new \think\Exception('该任务已经创建,请耐心等待处理完成!');
}
@@ -161,12 +166,10 @@ class Queue
/**
* 执行任务处理
- * @param Input $input 输入对象
- * @param Output $output 输出对象
* @param array $data 任务参数
* @return mixed
*/
- public function execute(Input $input, Output $output, array $data = [])
+ public function execute(array $data = [])
{
}
diff --git a/vendor/zoujingli/think-library/src/helper/TokenHelper.php b/vendor/zoujingli/think-library/src/helper/TokenHelper.php
index 973d8e834..b3545bb36 100644
--- a/vendor/zoujingli/think-library/src/helper/TokenHelper.php
+++ b/vendor/zoujingli/think-library/src/helper/TokenHelper.php
@@ -26,11 +26,6 @@ use think\exception\HttpResponseException;
*/
class TokenHelper extends Helper
{
- /**
- * 获取当前令牌值
- * @var string
- */
- protected $token;
/**
* 初始化验证码器
@@ -40,8 +35,7 @@ class TokenHelper extends Helper
public function init($return = false)
{
$this->class->csrf_state = true;
- $this->token = $this->app->request->header('user-form-token', input('_csrf_', ''));
- if ($this->app->request->isPost() && !TokenService::instance($this->app)->checkFormToken($this->token)) {
+ if ($this->app->request->isPost() && !TokenService::instance($this->app)->checkFormToken()) {
if ($return) return false;
$this->class->error($this->class->csrf_message);
} else {
@@ -54,8 +48,7 @@ class TokenHelper extends Helper
*/
public function clear()
{
- $this->token = $this->app->request->header('user-form-token', input('_csrf_', ''));
- if (!empty($this->token)) TokenService::instance($this->app)->clearFormToken($this->token);
+ TokenService::instance($this->app)->clearFormToken();
}
/**
diff --git a/vendor/zoujingli/think-library/src/queue/ListenQueue.php b/vendor/zoujingli/think-library/src/queue/ListenQueue.php
index d7826868a..308595fc8 100644
--- a/vendor/zoujingli/think-library/src/queue/ListenQueue.php
+++ b/vendor/zoujingli/think-library/src/queue/ListenQueue.php
@@ -55,14 +55,14 @@ class ListenQueue extends Command
try {
$this->app->db->name('SystemQueue')->where(['id' => $vo['id']])->update(['status' => '2', 'enter_time' => time(), 'attempts' => $vo['attempts'] + 1]);
if ($process->query($command = $process->think("xtask:_work {$vo['id']} -"))) {
- $output->comment("任务正在执行 --> [{$vo['id']}] {$vo['title']}");
+ $output->comment("正在执行 --> [{$vo['id']}] {$vo['title']}");
} else {
$process->create($command);
- $output->info("任务创建成功 --> [{$vo['id']}] {$vo['title']}");
+ $output->info("创建成功 --> [{$vo['id']}] {$vo['title']}");
}
} catch (\Exception $e) {
$this->app->db->name('SystemQueue')->where(['id' => $vo['id']])->update(['status' => '4', 'outer_time' => time(), 'exec_desc' => $e->getMessage()]);
- $output->error("任务创建失败 --> [{$vo['id']}] {$vo['title']},{$e->getMessage()}");
+ $output->error("创建失败 --> [{$vo['id']}] {$vo['title']},{$e->getMessage()}");
}
}
sleep(1);
diff --git a/vendor/zoujingli/think-library/src/queue/WorkQueue.php b/vendor/zoujingli/think-library/src/queue/WorkQueue.php
index 3ed0bebf1..2d0f3d838 100644
--- a/vendor/zoujingli/think-library/src/queue/WorkQueue.php
+++ b/vendor/zoujingli/think-library/src/queue/WorkQueue.php
@@ -56,7 +56,7 @@ class WorkQueue extends Command
* 任务执行
* @param Input $input
* @param Output $output
- * @throws \Exception
+ * @throws \think\db\exception\DbException
*/
protected function execute(Input $input, Output $output)
{
@@ -73,12 +73,13 @@ class WorkQueue extends Command
if (class_exists($command = $queue['command'])) {
if ($command instanceof Queue) {
$data = json_decode($queue['data'], true) ?: [];
- $this->update('3', $command::instance($this->app, $this->id)->execute($input, $output, $data));
+ $this->update('3', $command::instance($this->app, $this->id)->execute($data));
} else {
throw new \think\Exception("任务处理类 {$command} 未继承 think\\admin\\Queue");
}
} else {
- $this->update('3', $this->app->console->call($queue['command'], [], 'console'));
+ $attr = explode(' ', trim(preg_replace('|\s+|', ' ', $queue['command'])));
+ $this->update('3', $this->app->console->call(array_shift($attr), $attr, 'console'));
}
} catch (\Exception $e) {
$this->update('4', $e->getMessage());
@@ -94,8 +95,9 @@ class WorkQueue extends Command
*/
protected function update($status, $message)
{
+ $desc = explode("\n", trim(is_string($message) ? $message : ''));
$result = $this->app->db->name('SystemQueue')->where(['id' => $this->id])->update([
- 'status' => $status, 'outer_time' => date('Y-m-d H:i:s'), 'exec_desc' => is_string($message) ? $message : '',
+ 'status' => $status, 'outer_time' => time(), 'exec_desc' => $desc[0],
]);
$this->output->writeln(is_string($message) ? $message : '');
return $result !== false;
diff --git a/vendor/zoujingli/think-library/src/service/TokenService.php b/vendor/zoujingli/think-library/src/service/TokenService.php
index c28059522..793ae0f05 100644
--- a/vendor/zoujingli/think-library/src/service/TokenService.php
+++ b/vendor/zoujingli/think-library/src/service/TokenService.php
@@ -24,15 +24,27 @@ use think\admin\Service;
*/
class TokenService extends Service
{
+ /**
+ * 获取当前请求令牌
+ * @return array|string
+ */
+ public function getInputToken()
+ {
+ return $this->app->request->header('user-form-token', input('_csrf_', ''));
+ }
+
/**
* 验证表单令牌是否有效
* @param string $token 表单令牌
+ * @param string $node 授权节点
* @return boolean
*/
- public function checkFormToken($token)
+ public function checkFormToken($token = null, $node = null)
{
- $service = NodeService::instance($this->app);
- list($node, $cache) = [$service->getCurrent(), $this->app->session->get($token, [])];
+ if (is_null($token)) $token = $this->getInputToken();
+ if (is_null($node)) $node = NodeService::instance($this->app)->getCurrent();
+ // 读取缓存并检查是否有效
+ $cache = $this->app->session->get($token, []);
if (empty($cache['node']) || empty($cache['time']) || empty($cache['token'])) return false;
if ($cache['token'] !== $token || $cache['time'] + 600 < time() || $cache['node'] !== $node) return false;
return true;
@@ -40,11 +52,12 @@ class TokenService extends Service
/**
* 清理表单CSRF信息
- * @param string $name
+ * @param string $token
*/
- public function clearFormToken($name = null)
+ public function clearFormToken($token = null)
{
- $this->app->session->delete($name);
+ if (is_null($token)) $token = $this->getInputToken();
+ $this->app->session->delete($token);
}
/**