69 lines
1.7 KiB
PHP
69 lines
1.7 KiB
PHP
#!/usr/bin/env php
|
|
<?php
|
|
declare(strict_types=1);
|
|
|
|
require_once dirname(__DIR__) . '/config/fileload.php';
|
|
|
|
$targetModule = '';
|
|
$statusOnly = false;
|
|
|
|
foreach (array_slice($argv, 1) as $arg) {
|
|
$arg = trim((string) $arg);
|
|
if ($arg === '') {
|
|
continue;
|
|
}
|
|
if ($arg === '--status') {
|
|
$statusOnly = true;
|
|
continue;
|
|
}
|
|
if (str_starts_with($arg, '--module=')) {
|
|
$targetModule = trim(substr($arg, 9));
|
|
continue;
|
|
}
|
|
if ($targetModule === '') {
|
|
$targetModule = $arg;
|
|
}
|
|
}
|
|
|
|
$modules = app()->modules()->all();
|
|
$results = [];
|
|
|
|
foreach ($modules as $name => $meta) {
|
|
if (!is_string($name) || $name === '') {
|
|
continue;
|
|
}
|
|
if ($targetModule !== '' && $targetModule !== $name) {
|
|
continue;
|
|
}
|
|
if (empty($meta['enabled'])) {
|
|
continue;
|
|
}
|
|
|
|
$intervalDefs = app()->modules()->intervalTasks($name);
|
|
$cronDefs = app()->modules()->cronTasks($name);
|
|
if ($intervalDefs === [] && $cronDefs === []) {
|
|
continue;
|
|
}
|
|
|
|
if ($statusOnly) {
|
|
$results[$name] = [
|
|
'interval' => app()->modules()->intervalTaskStatuses($name),
|
|
'cron' => app()->modules()->cronTaskStatuses($name),
|
|
];
|
|
continue;
|
|
}
|
|
|
|
$results[$name] = [
|
|
'interval' => app()->modules()->runDueIntervalTasks($name),
|
|
'cron' => app()->modules()->runDueCronTasks($name),
|
|
];
|
|
}
|
|
|
|
echo json_encode([
|
|
'ok' => true,
|
|
'ran_at_utc' => gmdate('Y-m-d H:i:s'),
|
|
'module' => $targetModule !== '' ? $targetModule : null,
|
|
'mode' => $statusOnly ? 'status' : 'run',
|
|
'results' => $results,
|
|
], JSON_UNESCAPED_UNICODE | JSON_UNESCAPED_SLASHES | JSON_PRETTY_PRINT) . PHP_EOL;
|