diff --git a/Blacklight/TmuxRun.php b/Blacklight/TmuxRun.php index 177a0d6cb..9c176d8a5 100755 --- a/Blacklight/TmuxRun.php +++ b/Blacklight/TmuxRun.php @@ -194,7 +194,7 @@ class TmuxRun extends Tmux $log = $this->writelog($runVar['panes']['one'][1]); shell_exec( "tmux respawnp -t{$runVar['constants']['tmux_session']}:1.1 ' \ - {$runVar['commands']['_phpn']} {$runVar['paths']['misc']}update/multiprocessing/postprocess.php ama $log; \ + {$runVar['commands']['_phpn']} artisan multiprocessing:postprocess ama 2>&1 | tee -a $log; \ date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer_amazon']}' 2>&1 1> /dev/null" ); break; @@ -237,8 +237,8 @@ class TmuxRun extends Tmux $log = $this->writelog($runVar['panes']['two'][1]); shell_exec( "tmux respawnp -t{$runVar['constants']['tmux_session']}:2.1 ' \ - {$runVar['commands']['_php']} {$runVar['paths']['misc']}update/multiprocessing/postprocess.php tv $log; \ - {$runVar['commands']['_php']} {$runVar['paths']['misc']}update/multiprocessing/postprocess.php mov $log; \ + {$runVar['commands']['_php']} artisan multiprocessing:postprocess tv 2>&1 | tee -a $log; \ + {$runVar['commands']['_php']} artisan multiprocessing:postprocess mov 2>&1 | tee -a $log; \ {$runVar['commands']['_php']} {$runVar['paths']['misc']}update/postprocess.php anime true $log; \ {$runVar['commands']['_php']} {$runVar['paths']['misc']}testing/PostProc/check_covers.php true $log; \ date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer_non']}' 2>&1 1> /dev/null" @@ -338,7 +338,7 @@ class TmuxRun extends Tmux $color = $this->get_color($runVar['settings']['colors_start'], $runVar['settings']['colors_end'], $runVar['settings']['colors_exc']); shell_exec( "tmux respawnp -t{$runVar['constants']['tmux_session']}:2.0 'echo \"\033[38;5;{$color}m\"; \ - {$runVar['commands']['_php']} {$runVar['paths']['misc']}update/multiprocessing/postprocess.php add $log; date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer']}' 2>&1 1> /dev/null" + {$runVar['commands']['_php']} artisan multiprocessing:postprocess add 2>&1 | tee -a $log; date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer']}' 2>&1 1> /dev/null" ); $runVar['timers']['timer3'] = time(); break; @@ -346,7 +346,7 @@ class TmuxRun extends Tmux $log = $this->writelog($runVar['panes']['two'][0]); shell_exec( "tmux respawnp -t{$runVar['constants']['tmux_session']}:2.0 ' \ - {$runVar['commands']['_php']} {$runVar['paths']['misc']}update/multiprocessing/postprocess.php nfo $log; date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer']}' 2>&1 1> /dev/null" + {$runVar['commands']['_php']} artisan multiprocessing:postprocess nfo 2>&1 | tee -a $log; date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer']}' 2>&1 1> /dev/null" ); $runVar['timers']['timer3'] = time(); break; @@ -355,8 +355,8 @@ class TmuxRun extends Tmux $log = $this->writelog($runVar['panes']['two'][0]); shell_exec( "tmux respawnp -t{$runVar['constants']['tmux_session']}:2.0 ' \ - {$runVar['commands']['_php']} {$runVar['paths']['misc']}update/multiprocessing/postprocess.php add $log; \ - {$runVar['commands']['_php']} {$runVar['paths']['misc']}update/multiprocessing/postprocess.php nfo $log; \ + {$runVar['commands']['_php']} artisan multiprocessing:postprocess add 2>&1 | tee -a $log; \ + {$runVar['commands']['_php']} artisan multiprocessing:postprocess nfo 2>&1 | tee -a $log; \ date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['post_timer']}' 2>&1 1> /dev/null" ); $runVar['timers']['timer3'] = time(); @@ -482,7 +482,7 @@ class TmuxRun extends Tmux if ((int) $runVar['settings']['backfill'] !== 0) { shell_exec( "tmux respawnp -t{$runVar['constants']['tmux_session']}:0.1 ' \ - {$runVar['commands']['_php']} {$runVar['paths']['misc']}update/multiprocessing/backfill.php $log; \ + {$runVar['commands']['_php']} artisan multiprocessing:backfill 2>&1 | tee -a $log; \ date +\"{$this->_dateFormat}\"; {$runVar['commands']['_sleep']} {$runVar['settings']['seq_timer']}' 2>&1 1> /dev/null" ); $runVar['timers']['timer5'] = time(); diff --git a/app/Console/Commands/ProcessBackfill.php b/app/Console/Commands/ProcessBackfill.php new file mode 100644 index 000000000..385a6f05e --- /dev/null +++ b/app/Console/Commands/ProcessBackfill.php @@ -0,0 +1,52 @@ +argument('limit'); + + $options = []; + if (isset($limit) && is_numeric($limit) && $limit > 0) { + $options = [0 => (int) $limit]; + } else { + $options = [0 => false]; + } + + try { + (new Forking)->processWorkType('backfill', $options); + + return self::SUCCESS; + } catch (\Exception $e) { + Log::error($e->getTraceAsString()); + $this->error($e->getMessage()); + + return self::FAILURE; + } + } +} + diff --git a/app/Console/Commands/ProcessBinaries.php b/app/Console/Commands/ProcessBinaries.php new file mode 100644 index 000000000..4f3f13af0 --- /dev/null +++ b/app/Console/Commands/ProcessBinaries.php @@ -0,0 +1,45 @@ +argument('max'); + + try { + (new Forking)->processWorkType('binaries', [0 => $max]); + + return self::SUCCESS; + } catch (\Exception $e) { + Log::error($e->getMessage()); + $this->error($e->getMessage()); + + return self::FAILURE; + } + } +} + diff --git a/app/Console/Commands/ProcessFixRelNames.php b/app/Console/Commands/ProcessFixRelNames.php new file mode 100644 index 000000000..a950f15ad --- /dev/null +++ b/app/Console/Commands/ProcessFixRelNames.php @@ -0,0 +1,52 @@ +argument('type'); + + if (! \in_array($type, ['standard', 'predbft'], true)) { + $this->error('Type must be either: standard or predbft'); + $this->line(''); + $this->line('standard => Attempt to fix release name using standard methods'); + $this->line('predbft => Attempt to fix release name using Predb full text matching'); + + return self::FAILURE; + } + + try { + (new Forking)->processWorkType('fixRelNames_'.$type, [0 => $type]); + + return self::SUCCESS; + } catch (\Exception $e) { + $this->error($e->getMessage()); + + return self::FAILURE; + } + } +} + diff --git a/app/Console/Commands/ProcessPostProcess.php b/app/Console/Commands/ProcessPostProcess.php new file mode 100644 index 000000000..143b84d04 --- /dev/null +++ b/app/Console/Commands/ProcessPostProcess.php @@ -0,0 +1,63 @@ +argument('type'); + $renamed = $this->argument('renamed'); + + if (! \in_array($type, ['ama', 'add', 'mov', 'nfo', 'sha', 'tv'], true)) { + $this->error('Type must be one of: ama, add, mov, nfo, sha, tv'); + $this->line(''); + $this->line('ama => Do amazon processing (no multiprocessing due to API restrictions)'); + $this->line('add => Do additional (rar|zip) processing'); + $this->line('mov => Do movie processing'); + $this->line('nfo => Do NFO processing'); + $this->line('sha => Do sharing processing (no multiprocessing)'); + $this->line('tv => Do TV processing'); + + return self::FAILURE; + } + + try { + $options = []; + if ($renamed === 'true' || $renamed === true) { + $options = [0 => true]; + } + + (new Forking)->processWorkType('postProcess_'.$type, $options); + + return self::SUCCESS; + } catch (\Exception $e) { + $this->error($e->getMessage()); + + return self::FAILURE; + } + } +} + diff --git a/app/Console/Commands/ProcessReleasesMulti.php b/app/Console/Commands/ProcessReleasesMulti.php new file mode 100644 index 000000000..f491339f0 --- /dev/null +++ b/app/Console/Commands/ProcessReleasesMulti.php @@ -0,0 +1,40 @@ +processWorkType('releases'); + + return self::SUCCESS; + } catch (\Exception $e) { + $this->error($e->getMessage()); + + return self::FAILURE; + } + } +} + diff --git a/app/Console/Commands/ProcessSafe.php b/app/Console/Commands/ProcessSafe.php new file mode 100644 index 000000000..c2d34eae7 --- /dev/null +++ b/app/Console/Commands/ProcessSafe.php @@ -0,0 +1,52 @@ +argument('type'); + + if (! \in_array($type, ['backfill', 'binaries'], true)) { + $this->error('Type must be either: binaries or backfill'); + $this->line(''); + $this->line('binaries => Do Safe Binaries update'); + $this->line('backfill => Do Safe Backfill update'); + + return self::FAILURE; + } + + try { + (new Forking)->processWorkType('safe_'.$type); + + return self::SUCCESS; + } catch (\Exception $e) { + $this->error($e->getMessage()); + + return self::FAILURE; + } + } +} + diff --git a/app/Console/Commands/ProcessUpdatePerGroup.php b/app/Console/Commands/ProcessUpdatePerGroup.php new file mode 100644 index 000000000..01ccd76cc --- /dev/null +++ b/app/Console/Commands/ProcessUpdatePerGroup.php @@ -0,0 +1,40 @@ +processWorkType('update_per_group'); + + return self::SUCCESS; + } catch (\Exception $e) { + $this->error($e->getMessage()); + + return self::FAILURE; + } + } +} + diff --git a/app/Services/Tmux/Scripts/monitor.php b/app/Services/Tmux/Scripts/monitor.php index d34f5a34d..804e21a82 100644 --- a/app/Services/Tmux/Scripts/monitor.php +++ b/app/Services/Tmux/Scripts/monitor.php @@ -49,10 +49,10 @@ try { $runVar['commands']['_phpn'] = "nice -n{$tmux_niceness} php"; $runVar['commands']['_sleep'] = "{$runVar['commands']['_phpn']} ".base_path('app/Services/Tmux/Scripts/showsleep.php'); - // Add scripts paths for TmuxRun - Using multiprocessing scripts WITH ARGUMENTS - $runVar['scripts']['binaries'] = "nice -n{$tmux_niceness} php ".base_path('misc/update/multiprocessing/binaries.php').' 0'; - $runVar['scripts']['backfill'] = "nice -n{$tmux_niceness} php ".base_path('misc/update/multiprocessing/backfill.php').' 0'; - $runVar['scripts']['releases'] = "nice -n{$tmux_niceness} php ".base_path('misc/update/multiprocessing/releases.php'); + // Add scripts paths for TmuxRun - Using Artisan multiprocessing commands + $runVar['scripts']['binaries'] = "nice -n{$tmux_niceness} ".PHP_BINARY.' artisan multiprocessing:binaries 0'; + $runVar['scripts']['backfill'] = "nice -n{$tmux_niceness} ".PHP_BINARY.' artisan multiprocessing:backfill 0'; + $runVar['scripts']['releases'] = "nice -n{$tmux_niceness} ".PHP_BINARY.' artisan multiprocessing:releases'; // Spawn IRC scraper immediately try { diff --git a/app/Services/Tmux/TmuxTaskRunner.php b/app/Services/Tmux/TmuxTaskRunner.php index 21a019653..d9d77aa05 100644 --- a/app/Services/Tmux/TmuxTaskRunner.php +++ b/app/Services/Tmux/TmuxTaskRunner.php @@ -194,17 +194,17 @@ class TmuxTaskRunner return $this->disablePane($pane, 'Update Binaries', 'postprocess kill limit exceeded'); } - $script = match ((int) $enabled) { - 1 => base_path('misc/update/multiprocessing/safe.php binaries'), + $artisanCommand = match ((int) $enabled) { + 1 => 'multiprocessing:safe binaries', default => null, }; - if (! $script) { + if (! $artisanCommand) { return false; } $niceness = Settings::settingValue('niceness') ?? 2; - $command = "nice -n{$niceness} php {$script}"; + $command = "nice -n{$niceness} ".PHP_BINARY." artisan {$artisanCommand}"; $sleep = (int) ($config['settings']['bins_timer'] ?? 60); $command = $this->buildCommand($command, ['log_pane' => 'binaries', 'sleep' => $sleep]); @@ -229,13 +229,13 @@ class TmuxTaskRunner return $this->disablePane($pane, 'Backfill', 'kill limit exceeded'); } - $script = match ((int) $enabled) { - 1 => base_path('misc/update/multiprocessing/backfill.php'), - 4 => base_path('misc/update/multiprocessing/safe.php backfill'), + $artisanCommand = match ((int) $enabled) { + 1 => 'multiprocessing:backfill', + 4 => 'multiprocessing:safe backfill', default => null, }; - if (! $script) { + if (! $artisanCommand) { return false; } @@ -249,7 +249,7 @@ class TmuxTaskRunner : $baseSleep; $niceness = Settings::settingValue('niceness') ?? 2; - $command = "nice -n{$niceness} php {$script}"; + $command = "nice -n{$niceness} ".PHP_BINARY." artisan {$artisanCommand}"; $command = $this->buildCommand($command, ['log_pane' => 'backfill', 'sleep' => $sleep]); return $this->paneManager->respawnPane($pane, $command); @@ -267,9 +267,8 @@ class TmuxTaskRunner return $this->disablePane($pane, 'Update Releases', 'disabled in settings'); } - $script = base_path('misc/update/multiprocessing/releases.php'); $niceness = Settings::settingValue('niceness') ?? 2; - $command = "nice -n{$niceness} php {$script}"; + $command = "nice -n{$niceness} ".PHP_BINARY." artisan multiprocessing:releases"; $sleep = (int) ($config['settings']['rel_timer'] ?? 60); $command = $this->buildCommand($command, ['log_pane' => 'releases', 'sleep' => $sleep]); diff --git a/misc/update/multiprocessing/.gitignore b/misc/update/multiprocessing/.gitignore deleted file mode 100644 index 9f37e3549..000000000 --- a/misc/update/multiprocessing/.gitignore +++ /dev/null @@ -1 +0,0 @@ -/settings.php diff --git a/misc/update/multiprocessing/README.md b/misc/update/multiprocessing/README.md deleted file mode 100644 index 54d031838..000000000 --- a/misc/update/multiprocessing/README.md +++ /dev/null @@ -1,19 +0,0 @@ -####These multi-processing scripts require a POSIX compliant operating system and the PHP pcntl extension. - - -####binaries.php -This will download new headers for all active groups using your binaries threads site setting. -You can pass a argument, a number to limit the max amount of new headers to download. - - -####releases.php -This is identical to the python releases_threaded.py -This will create new releases/delete unwanted releases, process requestid's, categorize releases by group -using your release threads site setting. - - -####update_per_group.php: -This is identical to the python update_threaded.py -This will download new headers for all active groups, backfill 20k headers from all backfill enabled groups, -create new releases/delete unwanted releases, process requestid's, categorize releases, process additional and NFO -by group using your release threads site setting. \ No newline at end of file diff --git a/misc/update/multiprocessing/backfill.php b/misc/update/multiprocessing/backfill.php deleted file mode 100644 index 0164766fd..000000000 --- a/misc/update/multiprocessing/backfill.php +++ /dev/null @@ -1,13 +0,0 @@ -processWorkType('backfill', (isset($argv[1]) && is_numeric($argv[1]) && $argv[1] > 0 ? [0 => $argv[1]] : [0 => false])); -} catch (Exception $e) { - Log::error($e->getTraceAsString()); - echo $e->getMessage(); -} diff --git a/misc/update/multiprocessing/binaries.php b/misc/update/multiprocessing/binaries.php deleted file mode 100644 index f79cfefe8..000000000 --- a/misc/update/multiprocessing/binaries.php +++ /dev/null @@ -1,15 +0,0 @@ - (Number) Set to 0 to ignore, else fetches up to x new headers for every active group.'.PHP_EOL - ); -} -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; -use Blacklight\libraries\Forking; - -try { - (new Forking)->processWorkType('binaries', [0 => $argv[1]]); -} catch (Exception $e) { - echo $e->getMessage(); -} diff --git a/misc/update/multiprocessing/fixrelnames.php b/misc/update/multiprocessing/fixrelnames.php deleted file mode 100644 index 6c1b1f29a..000000000 --- a/misc/update/multiprocessing/fixrelnames.php +++ /dev/null @@ -1,19 +0,0 @@ - Attempt to fix release name using standard methods.'.PHP_EOL. - 'predbft => Attempt to fix release name using Predb full text matching.'.PHP_EOL.PHP_EOL - ); -} - -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; - -use Blacklight\libraries\Forking; - -try { - (new Forking)->processWorkType('fixRelNames_'.$argv[1], [0 => $argv[1]]); -} catch (Exception $e) { - echo $e->getMessage(); -} diff --git a/misc/update/multiprocessing/import.php b/misc/update/multiprocessing/import.php deleted file mode 100644 index f858d42ef..000000000 --- a/misc/update/multiprocessing/import.php +++ /dev/null @@ -1,34 +0,0 @@ - Delete the NZB files after they are imported (recommended), if you stop and restart you will have to go over the imported files again.'.PHP_EOL.PHP_EOL. - 'Fourth argument (optional)'.PHP_EOL. - 'true|false => Delete the NZB if importing it fails (not recommended).'.PHP_EOL. - 'Fifth argument (optional):'.PHP_EOL. - 'true|false => Use the NZB file name as the release name (not recommended), the names in the NZB are better.'.PHP_EOL.PHP_EOL. - 'Sixth argument (optional):'.PHP_EOL. - 'How many NZB files to import per process, if this is not set, it will do 50,000 per process.'.PHP_EOL.PHP_EOL. - 'Note that successfully imported NZB files WILL be deleted.'.PHP_EOL - - ); -} -(new ForkingImportNZB)->start( - $argv[1], - (isset($argv[2]) && is_numeric($argv[2]) && $argv[2] > 0 ? $argv[2] : 1), - (isset($argv[3]) && $argv[3] === 'true' ? 'true' : 'false'), - (isset($argv[4]) && $argv[4] === 'true' ? 'true' : 'false'), - (isset($argv[5]) && $argv[5] === 'true' ? 'true' : 'false'), - (isset($argv[6]) && is_numeric($argv[6]) && $argv[6] > 0 ? $argv[6] : 50000) -); diff --git a/misc/update/multiprocessing/postprocess.php b/misc/update/multiprocessing/postprocess.php deleted file mode 100644 index 4cc63ddac..000000000 --- a/misc/update/multiprocessing/postprocess.php +++ /dev/null @@ -1,25 +0,0 @@ - Do amazon processing, this does not use multi-processing, because of amazon API restrictions.'.PHP_EOL. - 'add => Do additional (rar|zip) processing.'.PHP_EOL. - 'mov => Do movie processing.'.PHP_EOL. - 'nfo => Do NFO processing.'.PHP_EOL. - 'sha => Do sharing processing, this does not use multi-processing.'.PHP_EOL. - 'tv => Do TV processing.'.PHP_EOL.PHP_EOL. - 'Second argument (optional):'.PHP_EOL. - 'true|false => Only post-process renamed releases. This is for the mov|tv options.'.PHP_EOL - ); -} - -use Blacklight\libraries\Forking; - -try { - (new Forking)->processWorkType('postProcess_'.$argv[1], (isset($argv[2]) && $argv[2] === 'true' ? [0 => true] : [])); -} catch (Exception $e) { - echo $e->getMessage(); -} diff --git a/misc/update/multiprocessing/releases.php b/misc/update/multiprocessing/releases.php deleted file mode 100644 index 3f5eda189..000000000 --- a/misc/update/multiprocessing/releases.php +++ /dev/null @@ -1,11 +0,0 @@ -processWorkType('releases'); -} catch (Exception $e) { - echo $e->getMessage(); -} diff --git a/misc/update/multiprocessing/requestid.php b/misc/update/multiprocessing/requestid.php deleted file mode 100644 index b0ac9f284..000000000 --- a/misc/update/multiprocessing/requestid.php +++ /dev/null @@ -1,11 +0,0 @@ -processWorkType('request_id'); -} catch (Exception $e) { - echo $e->getMessage(); -} diff --git a/misc/update/multiprocessing/safe.php b/misc/update/multiprocessing/safe.php deleted file mode 100644 index 4e2452e11..000000000 --- a/misc/update/multiprocessing/safe.php +++ /dev/null @@ -1,19 +0,0 @@ - Do Safe Binaries update.'.PHP_EOL. - 'backfill => Do Safe Backfill update.'.PHP_EOL - ); -} - -require_once dirname(__DIR__, 3).DIRECTORY_SEPARATOR.'bootstrap/autoload.php'; - -use Blacklight\libraries\Forking; - -try { - (new Forking)->processWorkType('safe_'.$argv[1]); -} catch (Exception $e) { - echo $e->getMessage(); -} diff --git a/misc/update/multiprocessing/update_per_group.php b/misc/update/multiprocessing/update_per_group.php deleted file mode 100644 index 19e13c2e8..000000000 --- a/misc/update/multiprocessing/update_per_group.php +++ /dev/null @@ -1,11 +0,0 @@ -processWorkType('update_per_group'); -} catch (Exception $e) { - echo $e->getMessage(); -}