-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathPlexCronJob.php
More file actions
executable file
·73 lines (57 loc) · 1.89 KB
/
Copy pathPlexCronJob.php
File metadata and controls
executable file
·73 lines (57 loc) · 1.89 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
<?php
namespace XcVm\Module\Plex;
use XcVm\Cli\CommandInterface;
use XcVm\Cli\CronTrait;
use XcVm\Core\Process\ProcessManager;
/**
* PlexCronJob — plex cron job
*
* @package XC_VM_Module_Plex
* @author Divarion_D <https://github.com/Divarion-D>
* @copyright 2025-2026 Vateron Media
* @link https://github.com/Vateron-Media/XC_VM
* @license AGPL-3.0 https://www.gnu.org/licenses/agpl-3.0.html
*/
require_once MAIN_HOME . 'Cli/CronTrait.php';
class PlexCronJob implements CommandInterface {
use CronTrait;
public function getName(): string {
return 'cron:plex';
}
public function getDescription(): string {
return 'Cron: Plex Sync — scan and synchronize media';
}
public function execute(array $rArgs): int {
if (!$this->assertRunAsXcVm()) {
return 1;
}
ini_set('memory_limit', -1);
setlocale(LC_ALL, 'en_US.UTF-8');
putenv('LC_ALL=en_US.UTF-8');
$this->registerShutdown();
ini_set('display_errors', 1);
ini_set('display_startup_errors', 1);
error_reporting(30711);
$rForce = null;
if (!empty($rArgs[0])) {
$rForce = intval($rArgs[0]);
}
if (!$rForce) {
if (file_exists(CACHE_TMP_PATH . 'plex_pid')) {
$rPrevPID = intval(file_get_contents(CACHE_TMP_PATH . 'plex_pid'));
} else {
$rPrevPID = null;
}
if ($rPrevPID && ProcessManager::isRunning($rPrevPID, 'php')) {
echo 'Plex Sync is already running. Please wait until it finishes.' . "\n";
return 0;
}
}
$this->rIdentifier = CACHE_TMP_PATH . 'plex_pid';
file_put_contents($this->rIdentifier, getmypid());
$this->setProcessTitle('XC_VM[Plex Sync]');
set_time_limit(0);
PlexCron::run($rForce);
return 0;
}
}