This commit is contained in:
2021-07-23 18:19:12 +08:00
parent 4a3b74950e
commit 81a316377b
+2 -10
View File
@@ -193,18 +193,14 @@ abstract class Crontab implements PipeMessage
*/ */
public function execute(): void public function execute(): void
{ {
defer(fn() => $this->afterExecute());
try { try {
defer(fn() => $this->afterExecute());
$redis = $this->application->getRedis(); $redis = $this->application->getRedis();
$name_md5 = $this->getName(); $name_md5 = $this->getName();
$redis->hSet(self::WAIT_END, $name_md5, static::getSerialize($this)); $redis->hSet(self::WAIT_END, $name_md5, static::getSerialize($this));
call_user_func([$this, 'process']); call_user_func([$this, 'process']);
$this->execute_number += 1; $this->execute_number += 1;
$redis->hDel(self::WAIT_END, $name_md5); $redis->hDel(self::WAIT_END, $name_md5);
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
$this->application->addError($throwable, 'throwable'); $this->application->addError($throwable, 'throwable');
@@ -221,7 +217,6 @@ abstract class Crontab implements PipeMessage
return; return;
} }
$redis = $this->application->getRedis(); $redis = $this->application->getRedis();
$name = $this->getName(); $name = $this->getName();
if (!$redis->exists('stop:crontab:' . $name)) { if (!$redis->exists('stop:crontab:' . $name)) {
$redis->set('crontab:' . $name, swoole_serialize($this)); $redis->set('crontab:' . $name, swoole_serialize($this));
@@ -275,10 +270,7 @@ abstract class Crontab implements PipeMessage
*/ */
private function isExit(): bool private function isExit(): bool
{ {
if ($this->isStop()) { if ($this->isStop() || !$this->isLoop) {
return true;
}
if (!$this->isLoop) {
return true; return true;
} }
return false; return false;