improve schedule not supported notice (#298)

This commit is contained in:
sunxyw
2023-02-11 22:15:02 +08:00
committed by GitHub
parent 50e20ebbc2
commit cedda65b18

View File

@@ -25,9 +25,6 @@ class Schedule
{
$c = Adaptive::getCoroutine();
$this->available = $c instanceof CoroutineInterface;
if (!$this->available) {
logger()->error('排程任务只能在协程环境下使用');
}
}
/**
@@ -38,6 +35,8 @@ class Schedule
public function addSchedule(Cron $cron): void
{
if (!$this->available) {
$location = $cron->class === '' ? $cron->method : $cron->class . '::' . $cron->method;
logger()->error('排程任务只能在协程环境下使用,排程任务 {location} 将不会被执行', ['location' => $location]);
return;
}
$next_run = $cron->expression->getNextRunDate()->getTimestamp();