From bb2dfcdaf99a10c2b123bf8d33f6a4d5ba3a9036 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Thu, 15 Apr 2021 20:23:01 +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 | 4 ++++ System/Crontab/Producer.php | 2 ++ 2 files changed, 6 insertions(+) diff --git a/System/Crontab/Crontab.php b/System/Crontab/Crontab.php index e52a8263..5c26ccc2 100644 --- a/System/Crontab/Crontab.php +++ b/System/Crontab/Crontab.php @@ -183,6 +183,10 @@ abstract class Crontab extends BaseObject private function recover() { $redis = Snowflake::app()->getRedis(); + if (!$redis->exists('stop:crontab:' . $this->getName())) { + $redis->del('stop:crontab:' . $this->getName()); + return; + } $redis->set('crontab:' . ($name = $this->getName()), swoole_serialize($this)); diff --git a/System/Crontab/Producer.php b/System/Crontab/Producer.php index c1805092..28ded719 100644 --- a/System/Crontab/Producer.php +++ b/System/Crontab/Producer.php @@ -52,6 +52,8 @@ class Producer extends Component { $redis = Snowflake::app()->getRedis(); + $redis->setex('stop:crontab:' . md5($name), 120, 1); + $redis->zRem(self::CRONTAB_KEY, $name); $redis->del('crontab:' . md5($name)); }