diff --git a/CHANGELOG.md b/CHANGELOG.md index ec1c6146e..18974b64a 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -18,6 +18,12 @@ Update from Maintenance > Update — Queue Update hands the job to cron and it a - Backups: the list of backups works like every other list - it sorts by its headings and has pages - and says more about each one: who made it or that the schedule did, when it was last downloaded, and why one failed. A backup's menu copies its path on the server, which is what restoring from the command line asks for, and its SHA-256 checksum, for checking a copy kept somewhere else. A backup still waiting to be made can be taken off the queue. - Backups: the nightly backup is on the page. It shows whether the schedule is on and at what time, with Turn on and Change the time beside it, so there is no trip to Maintenance > Cron. Beside the page, At a glance has the last Full Backup and the last Database Only, how many backups are kept and the room they take, the free space left where they are kept, and whether cron is running. - Backups: the encryption key is hidden until you click the eye, with a button to copy it; it used to sit on the page in full for anyone looking at the screen. Exporting the master key opens a window that asks for your password and says what will happen before it does. +- Cron: Maintenance > Cron is rebuilt so that its first line answers what you open it for - is cron running? The top of the page says when it last ran, how many jobs are on and which runs next. When something needs you, it says that instead: cron has never run on this server or has stopped, with the line to add to the server's crontab and a button that copies it; cron is switched off, with Turn cron on; or a job failed, by name. +- Cron: each job says what it does, its schedule and when it next runs, when it last ran and how long that took, and how it went. A job that failed says why under its name, and goes on saying so until you dismiss it - with a note once it has run since, so an old failure doesn't read as a new one. A job that skipped its run says why too: texting isn't set up, there is no Stripe provider, nothing was queued. +- Cron: the page keeps itself up to date. After Run now a job shows as queued, then running, then how it went, without a reload. And on a new server, once the cron line is in, the page says cron is running by itself. +- Cron: a job's menu has Run now, Change the schedule, Turn off - which asks first - and Copy the command to run it, which copies the command that runs that one job on the server, where it shows what it does as it goes. The list sorts by its headings, and starts in the order the day runs: the every-minute jobs, then the nightly ones by time. +- Cron: beside the page, At a glance has whether cron is running, when it last ran, how many jobs are on and off, any that failed, what runs next, and the time zone the schedules are in. Turn cron off, which stops every job at once for a restored backup or a test copy, asks first and says what stops. +- Update, Backup and Cron: a page that is keeping itself up to date no longer reloads under you. It waits while a window or a menu is open, while you are typing in a field, and while you have text selected to copy. ### Bug Fixes @@ -39,6 +45,14 @@ Update from Maintenance > Update — Queue Update hands the job to cron and it a - The master key window is an ajax modal, `admin/modals/backup/backup_master_key.php`, in place of markup at the foot of the page. The encryption key field uses `data-toggle="password"` and the copy buttons `clipboardjs`, both already in `js/app.js`. - `delete_backup` (`admin/post/backup.php`) reads the row's status so that the audit log and the message say what happened: a `Pending` row is "took a queued Full Backup off the queue", a `Complete` one "Backup deleted.", and any other "Backup removed from the list." - Hooks for tests and scripts: `data-backup-state` on the hero, `data-backup-list` with `data-backup-id` and `data-backup-status` on each row, `data-backup-schedule` (`on` or `off`), `data-backup-glance`, `data-backup-folder`, `data-backup-key`, `data-backup-now`, `data-backup-cron-warning` and `data-backup-master-key`. +- `admin/cron.php` is rewritten on the pattern of `admin/update.php` and `admin/backup.php`: one `$state` - `never`, `stopped`, `off`, `paused`, `failed` or `running`, tried in that order - picks the hero card's icon, tone and title from `$hero`. `never` and `stopped` are no heartbeat (`config_cron_last_dispatch_at`) at all, and none in five minutes; `off` is `config_enable_cron`; `paused` is a managed instance its manager has made read-only (`managedMode()`, `MANAGED_KEEP_JOBS`); `failed` is any job whose last run is `Failed`, or still `Running` six hours on. The card carries `data-itflow-reload-seconds`: 10 while a job is queued or started in the last half hour, 15 while cron hasn't been heard from. No CSS is added. +- The jobs are the registry's (`cronJobRegistry()`), each with its `cron_jobs` row, sorted in PHP on the standard `sort` and `order` - `job`, `schedule`, `last_run` or `status`, anything else falling back to `schedule`. There are no pages and no search on purpose: it is a fixed list of at most fifteen, and a job that failed mustn't be on page two. Each job is a `
` of two rows, so its description, why it was skipped and its error run the width of the table. A job the dispatcher hasn't met has no row and no menu. +- How the page reads `cron_job_last_status`: `Completed` and `Failed` as they are; `Stopped:' . escapeHtml($cron_command) . ''
+ . ''
+ . '' . escapeHtml($file_owner) . ' here)' : '';
+
+// The list - only these sort; anything else asked for falls back to the schedule
+$sort_keys = [
+ 'job' => function ($job) { return strtolower($job['label']); },
+ 'schedule' => function ($job) { return $job['schedule'] === 'Daily' ? 100000 + intval(substr($job['daily_at'], 0, 2)) * 60 + intval(substr($job['daily_at'], 3, 2)) : $job['interval_minutes']; },
+ 'last_run' => function ($job) { return $job['last_run_at'] ? strtotime($job['last_run_at']) : 0; },
+ // What needs a look first
+ 'status' => function ($job) { return array_search($job['state'], ['failed', 'lost', 'queued', 'running', 'paused', 'skipped', 'never', 'completed'], true); },
+];
+if (!isset($sort_keys[$sort])) {
+ $sort = 'schedule';
+}
+uasort($jobs, function ($a, $b) use ($sort_keys, $sort, $order) {
+ $compared = $sort_keys[$sort]($a) <=> $sort_keys[$sort]($b);
+ return ($order === 'DESC' ? -$compared : $compared) ?: $a['position'] <=> $b['position'];
+});
+// A heading sorts its own way round first - names A to Z, the latest run and what needs a look at the top - then the other
+$sort_first = ['job' => 'ASC', 'schedule' => 'ASC', 'last_run' => 'DESC', 'status' => 'ASC'];
+$sort_link = function ($column, $label) use ($url_query_strings_sort, $sort, $disp, $order_icon, $sort_first) {
+ return ''
+ . $label . ($sort === $column ? " $order_icon" : '') . '';
+};
+
+$status_looks = [
+ 'queued' => ['label' => 'Queued', 'tone' => 'warning'],
+ 'running' => ['label' => 'Running', 'tone' => 'primary'],
+ 'lost' => ['label' => "Didn't finish", 'tone' => 'danger'],
+ 'completed' => ['label' => 'Completed', 'tone' => 'success'],
+ 'failed' => ['label' => 'Failed', 'tone' => 'danger'],
+ 'skipped' => ['label' => 'Skipped', 'tone' => 'secondary'],
+ 'paused' => ['label' => 'Paused', 'tone' => 'warning'],
+ 'never' => ['label' => 'Not run yet', 'tone' => 'secondary'],
+];
+
?>
-= escapeHtml($cron_command) ?>-
- - The master switch is on. Turning it off - stops every job at once without touching their schedules, which is what you want on a restored - backup or a staging clone - those come up with every job enabled and will otherwise email clients - and charge cards. Switching back on returns you to exactly this configuration. - Turn cron off. - -
- + +| Job | -Schedule | -Last Run | -Duration | -Status | -Next Run | -Action | -
|---|---|---|---|---|---|---|
|
- = escapeHtml($job['label']) ?>
- Disabled
- = escapeHtml($job['description']) ?> - cron/= escapeHtml($job['script']) ?>
- |
- = escapeHtml(cronJobScheduleDescription($schedule, $interval_minutes, $daily_at)) ?> | -
- = escapeHtml(cronJobTimeAgo($last_run_at)) ?>
- = escapeHtml(date('M j, g:i A', strtotime($last_run_at))) ?> - |
- = $last_duration === null ? '-' : escapeHtml($last_duration) . 's' ?> | -
- = $status_badge ?>
- 9) { ?>
- = escapeHtml($last_status) ?> + + + It last ran = $ago($cron_last_dispatch_at) ?>. = count($jobs_on) ?> job= count($jobs_on) === 1 ? ' is' : 's are' ?> on= $jobs_off ? ", $jobs_off off" : '' ?>, and none failed on its last run. + + Next is = $job_names([$next_job]) ?>, = $next_job['next_run'] <= date('Y-m-d H:i:s') ? 'within a minute' : $ago($next_job['next_run']) ?>. + + + + + ++ = $job_names($jobs_recovered) ?> failed earlier and = count($jobs_recovered) === 1 ? 'has' : 'have' ?> run since - what went wrong is kept below until you dismiss it. + + + + ++ = $job_names($jobs_busy) ?> = count($jobs_busy) === 1 ? 'is' : 'are' ?> on = count($jobs_busy) === 1 ? 'its' : 'their' ?> way - this page keeps itself up to date. + + + + + +Cron is switched off here as well, so its jobs do nothing when it runs until it's turned on. - |
- = $next_run === null ? '-' : escapeHtml(cronJobTimeAgo($next_run)) ?> | -
-
-
-
+
- |
-
|
-
-
-
-
-
-
-
- Last error
- = escapeHtml(cronJobTimeAgo($last_error_at)) ?>
- = escapeHtml($last_error) ?>
- |
- ||||||
- - Run Now does not start the job in your browser - it asks the - dispatcher to pick it up on its next pass, so a job starts within a minute and still runs on the command - line with the same locking as a scheduled run. Detailed per-job output is in - App Logs. - -
+ +| = $sort_link('job', 'Job') ?> | += $sort_link('schedule', 'Schedule') ?> | += $sort_link('last_run', 'Last run') ?> | += $sort_link('status', 'Status') ?> | ++ | |
|---|---|---|---|---|---|
| + + | ++ = escapeHtml($job['label']) ?> + + Off + + | +
+ = escapeHtml($job['schedule_text']) ?>
+
+ Next = $job['next_run'] <= date('Y-m-d H:i:s') ? 'within a minute' : escapeHtml(timeAgo($job['next_run'])) ?>
+
+ |
+
+
+ = $ago($job['last_run_at']) ?>
+
+ Took = escapeHtml($took($job['last_duration'])) ?>
+
+
+ —
+
+ |
+ + = escapeHtml($look['label']) ?> + | +
+
+
+
+
+
+
+ |
+
|
+ = escapeHtml($job['description']) ?>
+
+
+ = escapeHtml($job['schedule_text']) ?>= $job['last_run_at'] ? ' · last run ' . escapeHtml(timeAgo($job['last_run_at'])) : '' ?>
+
+
+
+ Asked to run now - = $cron_heard ? 'cron picks it up within a minute' : 'it runs as soon as cron does' ?>.
+
+ It started = $ago($job['last_run_at']) ?> and never said how it ended - most likely cut off by a restart or a time limit. It runs again when it's next due, or sooner with Run now.
+
+ It stopped early without saying why - App Logs may have it.
+
+ = escapeHtml($reason) ?>
+
+
+
+
+
+
+
+
+
+ Dismiss
+
+ Failed = $job['last_error_at'] ? $ago($job['last_error_at']) : 'earlier' ?>= $failing ? '' : ' - it has run since' ?>
+
+ = escapeHtml($job['last_error']) ?>
+ |
+ |||||
Everything on this page runs from one line in the server's crontab - that of the user that owns ITFlow's files= $owner_note ?>:
+ = $command_block() ?> +It runs every minute and works out which jobs are due, so changing a job's schedule here never means changing it. On a hosting control panel, it's a cron job that runs every minute.
+Stops every job at once, without touching their schedules. It's for a restored backup or a test copy, which would otherwise email your clients and charge their cards. Turning it back on picks up exactly where this leaves off.
+ + Turn cron off + += escapeHtml($job['description']) ?>
+ +