mirror of
https://github.com/myronblair/jarvis
synced 2026-07-28 00:34:35 -05:00
Fix WEB HOST stats never populating (DO server had no monitoring agent installed) and a timezone bug in freshness checks (America/Chicago default timezone + strtotime() on naive UTC MySQL timestamps caused sites/proxmox/ollama facts to never refresh, and could have suppressed the KB intent generator's scheduled runs)
This commit is contained in:
@@ -71,11 +71,14 @@ function normalize_pattern(string $pat): string {
|
||||
|
||||
/* ── run guard: skip if ran within last 4 hours ── */
|
||||
/* Set JARVIS_FORCE_RUN=1 (env) or pass --force (argv) to bypass */
|
||||
$lastRun = JarvisDB::single(
|
||||
"SELECT updated_at FROM kb_facts WHERE category='kb_generator' AND fact_key='last_run'"
|
||||
/* Comparison done in SQL (NOW()) rather than PHP time()/strtotime() — this process's
|
||||
date_default_timezone_set('America/Chicago') makes strtotime() misread MySQL's naive
|
||||
(UTC) timestamps as Chicago time, throwing elapsed-time checks off by the UTC offset. */
|
||||
$recentRun = JarvisDB::single(
|
||||
"SELECT (updated_at > DATE_SUB(NOW(), INTERVAL 14400 SECOND)) AS is_recent FROM kb_facts WHERE category='kb_generator' AND fact_key='last_run'"
|
||||
);
|
||||
$forceRun = !empty(getenv('JARVIS_FORCE_RUN')) || (isset($argv[1]) && $argv[1] === '--force');
|
||||
if (!$forceRun && $lastRun && (time() - strtotime($lastRun['updated_at'])) < 14400) {
|
||||
if (!$forceRun && $recentRun && $recentRun['is_recent']) {
|
||||
log_line('Skipping – ran within last 4 hours. Use --force to override.');
|
||||
exit(0);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user