add workaround for due tasks because housekeeping is not run every minute, fix last_run not updated to NOW() in the db

This commit is contained in:
Andrew Dolgov 2025-05-02 14:03:45 +03:00
parent 247efe3137
commit dc6ea08ca4
No known key found for this signature in database
GPG Key ID: 1A56B4FA25D4AF2A

View File

@ -965,7 +965,9 @@ class PluginHost {
Debug::log("Checking scheduled task: $task_name, last run: $last_run"); Debug::log("Checking scheduled task: $task_name, last run: $last_run");
if ($task['cron']->isDue($last_run)) { // because we don't schedule tasks every minute, we assume that task is due if its
// next estimated run based on previous timestamp is in the past
if ($task['cron']->getNextRunDate($last_run)->getTimestamp() - time() < 0) {
Debug::log("Task $task_name is due, executing..."); Debug::log("Task $task_name is due, executing...");
$task_started = time(); $task_started = time();
@ -977,7 +979,7 @@ class PluginHost {
Debug::log("Task $task_name has finished in $task_duration seconds with RC=$rc, recording timestamp..."); Debug::log("Task $task_name has finished in $task_duration seconds with RC=$rc, recording timestamp...");
if ($task_record) { if ($task_record) {
$task_record->last_run = time(); $task_record->last_run = Db::NOW();
$task_record->last_duration = $task_duration; $task_record->last_duration = $task_duration;
$task_record->last_rc = $rc; $task_record->last_rc = $rc;