Files
CLOAK/tools/visitor_log_worker.php
2026-06-15 22:42:59 +08:00

31 lines
768 B
PHP
Executable File

<?php
/**
* 访客日志异步队列 Worker(建议 cron 每分钟执行)
*
* php tools/visitor_log_worker.php
*/
$root = dirname(__DIR__);
require_once $root . '/cong.php';
require_once $root . '/lib/Cloak/VisitorLogWorker.php';
$limit = 100;
$rounds = 10;
$total = ['processed' => 0, 'failed' => 0];
for ($i = 0; $i < $rounds; $i++) {
$result = VisitorLogWorker::processBatch($limit);
$total['processed'] += $result['processed'];
$total['failed'] += $result['failed'];
if ($result['processed'] === 0) {
break;
}
}
if (PHP_SAPI === 'cli') {
echo json_encode([
'ok' => true,
'processed' => $total['processed'],
'failed' => $total['failed'],
], JSON_UNESCAPED_UNICODE) . "\n";
}