From b4a06d8f4bf1673008488cbf499f520b8ceed509 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Wed, 14 Apr 2021 14:46:55 +0800 Subject: [PATCH] =?UTF-8?q?=E6=94=B9=E5=90=8D?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- System/Crontab/Crontab.php | 11 +++++++---- System/Crontab/Zookeeper.php | 1 - 2 files changed, 7 insertions(+), 5 deletions(-) diff --git a/System/Crontab/Crontab.php b/System/Crontab/Crontab.php index 9edb6d4c..1319a840 100644 --- a/System/Crontab/Crontab.php +++ b/System/Crontab/Crontab.php @@ -4,10 +4,10 @@ namespace Snowflake\Crontab; -use Closure; use Exception; use JetBrains\PhpStorm\Pure; use Snowflake\Abstracts\BaseObject; +use Snowflake\Core\Json; use Snowflake\Snowflake; use Swoole\Timer; @@ -194,10 +194,10 @@ abstract class Crontab extends BaseObject } - abstract public function process(): mixed; abstract public function max_execute(): mixed; + abstract public function isStop(): bool; @@ -220,8 +220,11 @@ abstract class Crontab extends BaseObject if ($params === null) { return; } - $name = date('Y_m_d_H_i_s.' . $this->name . '.log'); - write(storage($name, '/log/crontab'), serialize($params)); + $name = date('Y-m-d.log'); + write(storage($name, '/log/crontab'), Json::encode([ + 'name' => $this->name, + 'response' => serialize($params) + ])); } catch (\Throwable $throwable) { logger()->addError($throwable, 'throwable'); } finally { diff --git a/System/Crontab/Zookeeper.php b/System/Crontab/Zookeeper.php index dea6aca3..08c7c444 100644 --- a/System/Crontab/Zookeeper.php +++ b/System/Crontab/Zookeeper.php @@ -84,7 +84,6 @@ class Zookeeper extends Process $range = $redis->zRangeByScore(Producer::CRONTAB_KEY, '0', (string)$startTime); $redis->zRemRangeByScore(Producer::CRONTAB_KEY, '0', (string)$startTime); - print_r($range); return [$range, $redis]; }