mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-14 20:40:49 +08:00
cleanup delay
This commit is contained in:
@@ -303,19 +303,21 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
$requestId = nexus()->getRequestId();
|
||||
$maxUidRes = mysql_fetch_assoc(sql_query("select max(id) as max_uid from users limit 1"));
|
||||
$maxUid = $maxUidRes['max_uid'];
|
||||
$phpPath = nexus_env('PHP_PATH') ?: 'php';
|
||||
$webRoot = rtrim(ROOT_PATH, '/');
|
||||
$chunk = 1000;
|
||||
$beginUid = 0;
|
||||
do_log("maxUid: $maxUid, chunk: $chunk");
|
||||
$chunkCounts = ceil($maxUid / $chunk);
|
||||
$delay = ceil(600/$chunkCounts);
|
||||
$i = 0;
|
||||
do_log("maxUid: $maxUid, chunk: $chunk, chunkCounts: $chunkCounts");
|
||||
do {
|
||||
$command = sprintf(
|
||||
'%s %s/artisan cleanup --action=seed_bonus --begin_id=%s --end_id=%s --request_id=%s',
|
||||
$phpPath, $webRoot, $beginUid, $beginUid + $chunk, $requestId
|
||||
'cleanup --action=seed_bonus --begin_id=%s --end_id=%s --request_id=%s --delay=%s',
|
||||
$beginUid, $beginUid + $chunk, $requestId, $i * $delay
|
||||
);
|
||||
$result = exec("$command 2>&1", $output, $result_code);
|
||||
do_log(sprintf('command: %s, result_code: %s, result: %s, output: %s', $command, $result_code, $result, json_encode($output)));
|
||||
$output = executeCommand($command, 'string', true);
|
||||
do_log(sprintf('command: %s, output: %s', $command, $output));
|
||||
$beginUid += $chunk;
|
||||
$i++;
|
||||
} while ($beginUid < $maxUid);
|
||||
|
||||
$log = 'calculate seeding bonus';
|
||||
@@ -407,15 +409,20 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
$maxTorrentId = $maxTorrentIdRes['max_torrent_id'];
|
||||
$chunk = 1000;
|
||||
$beginTorrentId = 0;
|
||||
do_log("maxTorrentId: $maxTorrentId, chunk: $chunk");
|
||||
$chunkCounts = ceil($maxTorrentId / $chunk);
|
||||
$delayBase = 600;
|
||||
$delay = ceil(600/$chunkCounts);
|
||||
$i = 0;
|
||||
do_log("maxUid: $maxUid, chunk: $chunk, chunkCounts: $chunkCounts");
|
||||
do {
|
||||
$command = sprintf(
|
||||
'%s %s/artisan cleanup --action=seeders_etc --begin_id=%s --end_id=%s --request_id=%s',
|
||||
$phpPath, $webRoot, $beginTorrentId, $beginTorrentId + $chunk, $requestId
|
||||
'cleanup --action=seeders_etc --begin_id=%s --end_id=%s --request_id=%s --delay=%s',
|
||||
$beginTorrentId, $beginTorrentId + $chunk, $requestId, $delayBase + $i * $delay
|
||||
);
|
||||
$result = exec("$command 2>&1", $output, $result_code);
|
||||
do_log(sprintf('command: %s, result_code: %s, result: %s, output: %s', $command, $result_code, $result, json_encode($output)));
|
||||
$output = executeCommand($command, 'string', true);
|
||||
do_log(sprintf('command: %s, output: %s', $command, $output));
|
||||
$beginTorrentId += $chunk;
|
||||
$i++;
|
||||
} while ($beginTorrentId < $maxTorrentId);
|
||||
$log = "update count of seeders, leechers, comments for torrents";
|
||||
do_log($log);
|
||||
|
||||
Reference in New Issue
Block a user