Files
nexusphp/include/cleanup_cli.php

31 lines
617 B
PHP
Raw Normal View History

2021-05-31 21:04:49 +08:00
<?php
/**
* do clean in cli
*
*/
require "bittorrent.php";
$fd = fopen(sprintf('%s/nexus_cleanup_cli.lock', sys_get_temp_dir()), 'w+');
if (!flock($fd, LOCK_EX|LOCK_NB)) {
do_log("can not get lock, skip!");
}
register_shutdown_function(function () use ($fd) {
fclose($fd);
});
2021-06-15 02:02:09 +08:00
$force = 0;
if (isset($_SERVER['argv'][1])) {
$force = $_SERVER['argv'][1] ? 1 : 0;
}
2021-05-31 21:04:49 +08:00
try {
2021-06-15 02:02:09 +08:00
$result = autoclean($force, true);
2021-06-01 15:50:17 +08:00
do_log("[CLEANUP_CLI DONE!] $result");
2021-05-31 21:04:49 +08:00
} catch (\Exception $exception) {
do_log("ERROR: " . $exception->getMessage());
throw new \RuntimeException($exception->getMessage());
}