修改自动推广的相关任务

This commit is contained in:
wangjinlei
2026-05-08 17:59:08 +08:00
parent 336fa08a18
commit c36eba77b1
4 changed files with 7 additions and 100 deletions

View File

@@ -1795,58 +1795,6 @@ class EmailClient extends Base
return jsonSuccess();
}
/**
* 队列写入测试:推一条 myTestQueue并返回 push 返回值 + 与 queueDebug 相同 Redis 下的 LLEN便于对照 redis-cli
*/
public function mytestQueue()
{
$queueName = 'myTestQueue';
$jobClass = 'app\\api\\job\\myQueue@fire';
$data = ['testData' => 1];
$cfg = Config::get('queue');
$connector = isset($cfg['connector']) ? (string)$cfg['connector'] : '';
if (stripos($connector, 'sync') !== false) {
return jsonError('queue connector is Sync — will not write Redis. Check application/extra/queue.php');
}
if (!extension_loaded('redis')) {
return jsonError('PHP redis extension not loaded — Queue Redis connector cannot run.');
}
try {
$jobId = Queue::push($jobClass, $data, $queueName);
} catch (\Throwable $e) {
return jsonError('Queue::push failed: ' . $e->getMessage());
}
// 独立连一次 Redis确认与 PHP-FPM 使用的配置一致且 LIST 长度(避免「以为写了其实没有」)
$verify = ['ready_len' => null, 'error' => null];
try {
$redis = new \Redis();
$connectMethod = !empty($cfg['persistent']) ? 'pconnect' : 'connect';
$redis->$connectMethod($cfg['host'] ?? '127.0.0.1', $cfg['port'] ?? 6379);
if (!empty($cfg['password'])) {
$redis->auth($cfg['password']);
}
$redis->select($cfg['select'] ?? 0);
$readyKey = 'queues:' . $queueName;
$verify['ready_len'] = (int)$redis->lLen($readyKey);
$verify['exists'] = (bool)$redis->exists($readyKey);
$verify['ping'] = (string)$redis->ping();
$verify['checked_db'] = (int)($cfg['select'] ?? 0);
$verify['checked_host'] = (string)($cfg['host'] ?? '127.0.0.1');
$verify['checked_port'] = (int)($cfg['port'] ?? 6379);
} catch (\Throwable $e) {
$verify['error'] = $e->getMessage();
}
return jsonSuccess([
'job_id' => $jobId,
'queue' => $queueName,
'connector' => $connector,
'after_push' => $verify,
]);
}
/**
* 队列调试:查看 Redis 里队列长度(不依赖 redis-cli