|
@@ -8,9 +8,9 @@ use think\Cache;
|
|
|
use Workerman\Crontab\Crontab;
|
|
use Workerman\Crontab\Crontab;
|
|
|
use Workerman\Worker;
|
|
use Workerman\Worker;
|
|
|
|
|
|
|
|
-readonly class SystemCron
|
|
|
|
|
|
|
+class SystemCron
|
|
|
{
|
|
{
|
|
|
- public function __construct(private Cache $cache)
|
|
|
|
|
|
|
+ public function __construct(private Cache $cache, private bool $isStart = false)
|
|
|
{
|
|
{
|
|
|
}
|
|
}
|
|
|
|
|
|
|
@@ -20,14 +20,18 @@ readonly class SystemCron
|
|
|
$crontabList = [];
|
|
$crontabList = [];
|
|
|
foreach (Crontab::getAll() as $item) {
|
|
foreach (Crontab::getAll() as $item) {
|
|
|
/* @var Crontab $item */
|
|
/* @var Crontab $item */
|
|
|
- $crontabList[] = [
|
|
|
|
|
|
|
+ $item = [
|
|
|
'rule' => $item->getRule(),
|
|
'rule' => $item->getRule(),
|
|
|
'name' => $item->getName(),
|
|
'name' => $item->getName(),
|
|
|
'id' => $item->getId(),
|
|
'id' => $item->getId(),
|
|
|
'time' => date('Y-m-d H:i:s'),
|
|
'time' => date('Y-m-d H:i:s'),
|
|
|
];
|
|
];
|
|
|
- Worker::safeEcho('[Cron] ' . $item->getName() . ' ' . $item->getRule() . "\n");
|
|
|
|
|
|
|
+ $crontabList[] = $item;
|
|
|
|
|
+ if (!$this->isStart) {
|
|
|
|
|
+ Worker::safeEcho(sprintf('[%s] [%s] [%s] [%s]', $item['time'], $item['id'], $item['name'], $item['rule']) . "\n");
|
|
|
|
|
+ }
|
|
|
}
|
|
}
|
|
|
$this->cache->set('crontab_list', $crontabList);
|
|
$this->cache->set('crontab_list', $crontabList);
|
|
|
|
|
+ $this->isStart = true;
|
|
|
}
|
|
}
|
|
|
}
|
|
}
|