71 lines
1.5 KiB
PHP
71 lines
1.5 KiB
PHP
<?php
|
|
|
|
declare(strict_types=1);
|
|
|
|
namespace App\Services;
|
|
|
|
use App\Services\Cron\HttpQueue as CronHttpQueue;
|
|
use App\Services\Cron\Book as CronBook;
|
|
use App\Services\Cron\ArticleSchema as CronArticleSchema;
|
|
use App\Services\TomTool\Telegram\Slave as TeleSlave;
|
|
|
|
final class Cron
|
|
{
|
|
public bool $bIsTest = false;
|
|
public ?int $iTestH = null;
|
|
public ?int $iTestI = null;
|
|
public ?int $iTestS = null;
|
|
|
|
public function run(): void
|
|
{
|
|
$h = (int) date("H");
|
|
$i = (int) date("i");
|
|
$s = (int) date("s");
|
|
|
|
if ($this->bIsTest) {
|
|
$h = (int) ($this->iTestH ?? $h);
|
|
$i = (int) ($this->iTestI ?? $i);
|
|
$s = (int) ($this->iTestS ?? $s);
|
|
}
|
|
|
|
echo "cron开始执行\n\n";
|
|
|
|
if ($h % 6 === 0 && $i === 3) {
|
|
CronBook::randbox_notify();
|
|
}
|
|
|
|
if ($i % 3 === 0) {
|
|
CronArticleSchema::cacheTgSave();
|
|
CronArticleSchema::pushToSlave();
|
|
CronHttpQueue::pop();
|
|
}
|
|
|
|
if ($i === 0) {
|
|
// ReportSender::handle();
|
|
}
|
|
}
|
|
|
|
public function setTestH(int $h): void
|
|
{
|
|
$this->enableTestMode();
|
|
$this->iTestH = $h;
|
|
}
|
|
|
|
public function setTestI(int $i): void
|
|
{
|
|
$this->enableTestMode();
|
|
$this->iTestI = $i;
|
|
}
|
|
|
|
public function setTestS(int $s): void
|
|
{
|
|
$this->enableTestMode();
|
|
$this->iTestS = $s;
|
|
}
|
|
|
|
public function enableTestMode(bool $enable = true): void
|
|
{
|
|
$this->bIsTest = $enable;
|
|
}
|
|
}
|