From 81a316377bccb5362cf82b85941109b59ff4c568 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Mr=C2=B7x?= Date: Fri, 23 Jul 2021 18:19:12 +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 | 12 ++---------- 1 file changed, 2 insertions(+), 10 deletions(-) diff --git a/System/Crontab/Crontab.php b/System/Crontab/Crontab.php index 28cc2e5e..6b4c274c 100644 --- a/System/Crontab/Crontab.php +++ b/System/Crontab/Crontab.php @@ -193,18 +193,14 @@ abstract class Crontab implements PipeMessage */ public function execute(): void { - defer(fn() => $this->afterExecute()); try { + defer(fn() => $this->afterExecute()); $redis = $this->application->getRedis(); $name_md5 = $this->getName(); - $redis->hSet(self::WAIT_END, $name_md5, static::getSerialize($this)); - call_user_func([$this, 'process']); - $this->execute_number += 1; - $redis->hDel(self::WAIT_END, $name_md5); } catch (\Throwable $throwable) { $this->application->addError($throwable, 'throwable'); @@ -221,7 +217,6 @@ abstract class Crontab implements PipeMessage return; } $redis = $this->application->getRedis(); - $name = $this->getName(); if (!$redis->exists('stop:crontab:' . $name)) { $redis->set('crontab:' . $name, swoole_serialize($this)); @@ -275,10 +270,7 @@ abstract class Crontab implements PipeMessage */ private function isExit(): bool { - if ($this->isStop()) { - return true; - } - if (!$this->isLoop) { + if ($this->isStop() || !$this->isLoop) { return true; } return false;