mirror of
https://github.com/lkddi/nexusphp.git
synced 2026-04-22 02:47:27 +08:00
cleanp add delay option
This commit is contained in:
+19
-11
@@ -300,19 +300,22 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
// }
|
||||
|
||||
//chunk async
|
||||
$asyncTaskCount = 3;
|
||||
$baseDuration = floor($autoclean_interval_one / ($asyncTaskCount + 1));
|
||||
$delayBase = 0;
|
||||
$requestId = nexus()->getRequestId();
|
||||
$maxUidRes = mysql_fetch_assoc(sql_query("select max(id) as max_uid from users limit 1"));
|
||||
$maxUid = $maxUidRes['max_uid'];
|
||||
$chunk = 1000;
|
||||
$beginUid = 0;
|
||||
$chunkCounts = ceil($maxUid / $chunk);
|
||||
$delay = ceil(600/$chunkCounts);
|
||||
$delay = ceil($baseDuration/$chunkCounts);
|
||||
$i = 0;
|
||||
do_log("maxUid: $maxUid, chunk: $chunk, chunkCounts: $chunkCounts");
|
||||
do_log("autoclean_interval_one: $autoclean_interval_one, baseDuration: $baseDuration, maxUid: $maxUid, chunk: $chunk, chunkCounts: $chunkCounts, delayBase: $delayBase, delay: $delay");
|
||||
do {
|
||||
$command = sprintf(
|
||||
'cleanup --action=seed_bonus --begin_id=%s --end_id=%s --request_id=%s --delay=%s',
|
||||
$beginUid, $beginUid + $chunk, $requestId, $i * $delay
|
||||
$beginUid, $beginUid + $chunk, $requestId, $delayBase + $i * $delay
|
||||
);
|
||||
$output = executeCommand($command, 'string', true);
|
||||
do_log(sprintf('command: %s, output: %s', $command, $output));
|
||||
@@ -405,15 +408,15 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
// sql_query("UPDATE torrents SET " . implode(",", $update) . " WHERE id = $id") or sqlerr(__FILE__, __LINE__);
|
||||
// }
|
||||
|
||||
$delayBase = $baseDuration;
|
||||
$maxTorrentIdRes = mysql_fetch_assoc(sql_query("select max(id) as max_torrent_id from torrents limit 1"));
|
||||
$maxTorrentId = $maxTorrentIdRes['max_torrent_id'];
|
||||
$chunk = 1000;
|
||||
$beginTorrentId = 0;
|
||||
$chunkCounts = ceil($maxTorrentId / $chunk);
|
||||
$delayBase = 600;
|
||||
$delay = ceil(600/$chunkCounts);
|
||||
$delay = ceil($baseDuration/$chunkCounts);
|
||||
$i = 0;
|
||||
do_log("maxUid: $maxUid, chunk: $chunk, chunkCounts: $chunkCounts");
|
||||
do_log("maxTorrentId: $maxTorrentId, chunk: $chunk, chunkCounts: $chunkCounts, delayBase: $delayBase, delay: $delay");
|
||||
do {
|
||||
$command = sprintf(
|
||||
'cleanup --action=seeders_etc --begin_id=%s --end_id=%s --request_id=%s --delay=%s',
|
||||
@@ -913,15 +916,20 @@ function docleanup($forceAll = 0, $printProgress = false) {
|
||||
|
||||
$chunk = 1000;
|
||||
$beginUid = 0;
|
||||
do_log("maxUid: $maxUid, chunk: $chunk");
|
||||
$delayBase = $baseDuration * 2;
|
||||
$chunkCounts = ceil($maxUid / $chunk);
|
||||
$delay = ceil($baseDuration/$chunkCounts);
|
||||
$i = 0;
|
||||
do_log("maxUid: $maxUid, chunk: $chunk, chunkCounts: $chunkCounts, delayBase: $delayBase, delay: $delay");
|
||||
do {
|
||||
$command = sprintf(
|
||||
'%s %s/artisan cleanup --action=seeding_leeching_time --begin_id=%s --end_id=%s --request_id=%s',
|
||||
$phpPath, $webRoot, $beginUid, $beginUid + $chunk, $requestId
|
||||
'cleanup --action=seeding_leeching_time --begin_id=%s --end_id=%s --request_id=%s --delay=%s',
|
||||
$beginUid, $beginUid + $chunk, $requestId, $delayBase + $delay * $i
|
||||
);
|
||||
$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 = "update total seeding and leeching time of users";
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
<?php
|
||||
defined('VERSION_NUMBER') || define('VERSION_NUMBER', '1.8.2');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-04-30');
|
||||
defined('RELEASE_DATE') || define('RELEASE_DATE', '2023-05-06');
|
||||
defined('IN_TRACKER') || define('IN_TRACKER', false);
|
||||
defined('PROJECTNAME') || define("PROJECTNAME","NexusPHP");
|
||||
defined('NEXUSPHPURL') || define("NEXUSPHPURL","https://nexusphp.org");
|
||||
|
||||
Reference in New Issue
Block a user