This commit is contained in:
2021-04-16 10:18:02 +08:00
parent 391551840c
commit 1e16803814
+8 -8
View File
@@ -180,7 +180,7 @@ abstract class Crontab extends BaseObject
/** /**
* @throws Exception * @throws Exception
*/ */
private function recover() private function recover(): bool
{ {
$redis = Snowflake::app()->getRedis(); $redis = Snowflake::app()->getRedis();
if ($redis->exists('stop:crontab:' . $this->getName())) { if ($redis->exists('stop:crontab:' . $this->getName())) {
@@ -191,6 +191,7 @@ abstract class Crontab extends BaseObject
$tickTime = time() + $this->getTickTime(); $tickTime = time() + $this->getTickTime();
$redis->zAdd(Producer::CRONTAB_KEY, $tickTime, $name); $redis->zAdd(Producer::CRONTAB_KEY, $tickTime, $name);
} }
return true;
} }
@@ -214,22 +215,21 @@ abstract class Crontab extends BaseObject
/** /**
* @param $application
* @return bool|int * @return bool|int
* @throws \Exception * @throws Exception
*/ */
public function isRecover($application): bool|int public function isRecover(): bool|int
{ {
try { try {
$redis = Snowflake::app()->getRedis(); $redis = Snowflake::app()->getRedis();
if ($application->isExit()) { if ($this->isExit()) {
return $redis->del('crontab:' . $this->getName()); return $redis->del('crontab:' . $this->getName());
} }
if ($application->isMaxExecute()) { if ($this->isMaxExecute()) {
call_user_func([$application, 'max_execute'], ...$application->params); call_user_func([$this, 'max_execute'], ...$this->getParams());
return $redis->del('crontab:' . $this->getName()); return $redis->del('crontab:' . $this->getName());
} else { } else {
return $application->recover(); return $this->recover();
} }
} catch (\Throwable $throwable) { } catch (\Throwable $throwable) {
return logger()->addError($throwable, 'throwable'); return logger()->addError($throwable, 'throwable');