cron
This commit is contained in:
@@ -4,7 +4,27 @@ declare(strict_types=1);
|
||||
|
||||
require_once dirname(__DIR__) . '/config/fileload.php';
|
||||
|
||||
$targetModule = trim((string) ($argv[1] ?? ''));
|
||||
$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 = [];
|
||||
|
||||
@@ -19,8 +39,17 @@ foreach ($modules as $name => $meta) {
|
||||
continue;
|
||||
}
|
||||
|
||||
$taskDefs = app()->modules()->intervalTasks($name);
|
||||
if ($taskDefs === []) {
|
||||
$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;
|
||||
}
|
||||
|
||||
@@ -34,5 +63,6 @@ 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;
|
||||
|
||||
Reference in New Issue
Block a user