Scheduler UI polish + per-script verbose logging + coffee report as orchestrator
- Cron and Advanced button vertically aligned in their respective rows - Verbose checkbox next to Log button — saves immediately, persists to schedule.json - --log flag injected into cron lines, manual Run, and Dry Run when verbose enabled - Coffee report rewritten as lean orchestrator over COFFEE_REPORT_SCRIPTS array - COFFEE_REPORT_SCRIPTS added to master.conf (7 Sunday monitor scripts) - Scheduler Advanced tab auto-discovers children via existing array detection
This commit is contained in:
@@ -20,18 +20,24 @@ function vv_schedule_save(array $schedule): bool {
|
||||
return file_put_contents(SCHEDULE_FILE, json_encode($schedule, JSON_PRETTY_PRINT)) !== false;
|
||||
}
|
||||
|
||||
function vv_schedule_update(string $id, bool $enabled, string $cron): bool {
|
||||
function vv_schedule_update(string $id, bool $enabled, string $cron, bool $log_enabled = false): bool {
|
||||
$schedule = vv_schedule_load();
|
||||
$schedule[$id] = [
|
||||
'id' => $id,
|
||||
'enabled' => $enabled,
|
||||
'cron' => $cron,
|
||||
'updated' => date('c'),
|
||||
'id' => $id,
|
||||
'enabled' => $enabled,
|
||||
'cron' => $cron,
|
||||
'log_enabled' => $log_enabled,
|
||||
'updated' => date('c'),
|
||||
];
|
||||
if (!vv_schedule_save($schedule)) return false;
|
||||
return vv_cron_rebuild($schedule);
|
||||
}
|
||||
|
||||
function vv_job_flags(string $id): string {
|
||||
$schedule = vv_schedule_load();
|
||||
return !empty($schedule[$id]['log_enabled']) ? '--log' : '';
|
||||
}
|
||||
|
||||
define('LOG_DIR', '/var/log/varaverk');
|
||||
|
||||
function vv_job_log_path(string $id): string {
|
||||
@@ -52,7 +58,8 @@ function vv_cron_rebuild(array $schedule): bool {
|
||||
$logFile = vv_job_log_path($entry['id']);
|
||||
$logDir = dirname($logFile);
|
||||
if (!is_dir($logDir)) mkdir($logDir, 0755, true);
|
||||
$lines[] = "{$entry['cron']} " . CRON_USER . " bash \"$script\" >> \"$logFile\" 2>&1";
|
||||
$flags = !empty($entry['log_enabled']) ? ' --log' : '';
|
||||
$lines[] = "{$entry['cron']} " . CRON_USER . " bash \"$script\"$flags >> \"$logFile\" 2>&1";
|
||||
}
|
||||
$lines[] = "";
|
||||
|
||||
@@ -103,13 +110,14 @@ function vv_job_tree(): array {
|
||||
$id = 'Orchestrators/' . basename($path);
|
||||
$entry = $schedule[$id] ?? ['enabled' => false, 'cron' => ''];
|
||||
$orchs[] = [
|
||||
'id' => $id,
|
||||
'label' => basename($path, '.sh'),
|
||||
'desc' => vv_script_description($path),
|
||||
'type' => 'orchestrator',
|
||||
'enabled' => (bool)($entry['enabled'] ?? false),
|
||||
'cron' => $entry['cron'] ?? '',
|
||||
'children' => vv_script_children($path, $schedule),
|
||||
'id' => $id,
|
||||
'label' => basename($path, '.sh'),
|
||||
'desc' => vv_script_description($path),
|
||||
'type' => 'orchestrator',
|
||||
'enabled' => (bool)($entry['enabled'] ?? false),
|
||||
'cron' => $entry['cron'] ?? '',
|
||||
'log_enabled' => (bool)($entry['log_enabled'] ?? false),
|
||||
'children' => vv_script_children($path, $schedule),
|
||||
];
|
||||
}
|
||||
return $orchs;
|
||||
@@ -148,12 +156,13 @@ function vv_script_children(string $orchPath, array $schedule): array {
|
||||
$seen[$rel] = true;
|
||||
$entry = $schedule[$rel] ?? ['enabled' => false, 'cron' => ''];
|
||||
$children[] = [
|
||||
'id' => $rel,
|
||||
'label' => basename($rel, '.sh'),
|
||||
'desc' => vv_script_description("$scriptsDir/$rel"),
|
||||
'type' => 'script',
|
||||
'enabled' => (bool)($entry['enabled'] ?? false),
|
||||
'cron' => $entry['cron'] ?? '',
|
||||
'id' => $rel,
|
||||
'label' => basename($rel, '.sh'),
|
||||
'desc' => vv_script_description("$scriptsDir/$rel"),
|
||||
'type' => 'script',
|
||||
'enabled' => (bool)($entry['enabled'] ?? false),
|
||||
'cron' => $entry['cron'] ?? '',
|
||||
'log_enabled' => (bool)($entry['log_enabled'] ?? false),
|
||||
];
|
||||
};
|
||||
|
||||
|
||||
Reference in New Issue
Block a user